protected function DateTimeHandlerTestBase::getRelativeDateValuesFromTimestamp in Drupal 9
Same name and namespace in other branches
- 8 core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php \Drupal\Tests\datetime\Kernel\Views\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/ tests/ src/ Kernel/ Views/ FilterDateTest.php - Create nodes with relative dates of yesterday, today, and tomorrow.
- 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::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 130
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),
];
}