public function DrupalDateTimeTest::testDefaultDateTime in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testDefaultDateTime()
- 9 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testDefaultDateTime()
Tests setting the default time for date-only objects.
File
- core/
tests/ Drupal/ Tests/ Core/ Datetime/ DrupalDateTimeTest.php, line 163
Class
- DrupalDateTimeTest
- @coversDefaultClass \Drupal\Core\Datetime\DrupalDateTime @group Datetime
Namespace
Drupal\Tests\Core\DatetimeCode
public function testDefaultDateTime() {
$utc = new \DateTimeZone('UTC');
$date = DrupalDateTime::createFromFormat('Y-m-d H:i:s', '2017-05-23 22:58:00', $utc, [
'langcode' => 'en',
]);
$this
->assertEquals('22:58:00', $date
->format('H:i:s'));
$date
->setDefaultDateTime();
$this
->assertEquals('12:00:00', $date
->format('H:i:s'));
}