function DateTimeHandlerTestBase::getRelativeDateValuesFromTimestamp
Returns an array formatted date_only values relative to timestamp.
Parameters
int $timestamp: Unix Timestamp used as 'today'.
Return value
array An array of DateTimeItemInterface::DATE_STORAGE_FORMAT date values. In order tomorrow, today and yesterday.
4 calls to DateTimeHandlerTestBase::getRelativeDateValuesFromTimestamp()
- FilterDateTest::setUp in core/modules/ datetime_range/ tests/ src/ Kernel/ Views/ FilterDateTest.php 
- Create nodes with relative date range of: yesterday - today, today - today, and today - tomorrow.
- FilterDateTest::setUp in core/modules/ datetime/ tests/ src/ Kernel/ Views/ FilterDateTest.php 
- Create nodes with relative dates of yesterday, today, and tomorrow.
- FilterDateTest::testDateIs in core/modules/ datetime/ tests/ src/ Kernel/ Views/ FilterDateTest.php 
- Tests date filter with date-only fields.
- FilterDateTest::testDateOffsets in core/modules/ datetime/ tests/ src/ Kernel/ Views/ FilterDateTest.php 
- Tests offsets with date-only fields.
File
- 
              core/modules/ datetime/ tests/ src/ Kernel/ Views/ DateTimeHandlerTestBase.php, line 137 
Class
- DateTimeHandlerTestBase
- Base class for testing datetime handlers.
Namespace
Drupal\Tests\datetime\Kernel\ViewsCode
protected function getRelativeDateValuesFromTimestamp($timestamp) {
  return [
    // Tomorrow.
\Drupal::service('date.formatter')->format($timestamp + 86400, 'custom', DateTimeItemInterface::DATE_STORAGE_FORMAT, DateTimeItemInterface::STORAGE_TIMEZONE),
    // Today.
\Drupal::service('date.formatter')->format($timestamp, 'custom', DateTimeItemInterface::DATE_STORAGE_FORMAT, DateTimeItemInterface::STORAGE_TIMEZONE),
    // Yesterday.
\Drupal::service('date.formatter')->format($timestamp - 86400, 'custom', DateTimeItemInterface::DATE_STORAGE_FORMAT, DateTimeItemInterface::STORAGE_TIMEZONE),
  ];
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
