function DateTimeHandlerTestBase::getUTCEquivalentOfUserNowAsTimestamp
Same name in other branches
- 9 core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php \Drupal\Tests\datetime\Kernel\Views\DateTimeHandlerTestBase::getUTCEquivalentOfUserNowAsTimestamp()
- 8.9.x core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php \Drupal\Tests\datetime\Kernel\Views\DateTimeHandlerTestBase::getUTCEquivalentOfUserNowAsTimestamp()
- 11.x core/modules/datetime/tests/src/Kernel/Views/DateTimeHandlerTestBase.php \Drupal\Tests\datetime\Kernel\Views\DateTimeHandlerTestBase::getUTCEquivalentOfUserNowAsTimestamp()
Returns UTC timestamp of user's TZ 'now'.
The date field stores date_only values without conversion, considering them already as UTC. This method returns the UTC equivalent of user's 'now' as a unix timestamp, so they match using Y-m-d format.
Return value
int Unix timestamp.
4 calls to DateTimeHandlerTestBase::getUTCEquivalentOfUserNowAsTimestamp()
- 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 122
Class
- DateTimeHandlerTestBase
- Base class for testing datetime handlers.
Namespace
Drupal\Tests\datetime\Kernel\ViewsCode
protected function getUTCEquivalentOfUserNowAsTimestamp() {
$user_now = new DateTimePlus('now', new \DateTimeZone(date_default_timezone_get()));
$utc_equivalent = new DateTimePlus($user_now->format('Y-m-d H:i:s'), new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE));
return $utc_equivalent->getTimestamp();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.