You are here

private function DateTest::createTimestamp in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Datetime/DateTest.php \Drupal\Tests\Core\Datetime\DateTest::createTimestamp()
  2. 9 core/tests/Drupal/Tests/Core/Datetime/DateTest.php \Drupal\Tests\Core\Datetime\DateTest::createTimestamp()

Creates a UNIX timestamp given a date and time string in the format year-month-day hour:minute:seconds (e.g. 2013-12-11 10:09:08).

Parameters

string $dateTimeString: The formatted date and time string.

Return value

int The UNIX timestamp.

3 calls to DateTest::createTimestamp()
DateTest::providerTestFormatDiff in core/tests/Drupal/Tests/Core/Datetime/DateTest.php
Data provider for testFormatDiff().
DateTest::testFormatTimeDiffSince in core/tests/Drupal/Tests/Core/Datetime/DateTest.php
Tests the formatTimeDiffSince method.
DateTest::testFormatTimeDiffUntil in core/tests/Drupal/Tests/Core/Datetime/DateTest.php
Tests the formatTimeDiffUntil method.

File

core/tests/Drupal/Tests/Core/Datetime/DateTest.php, line 428

Class

DateTest
@coversDefaultClass \Drupal\Core\Datetime\DateFormatter @group Datetime

Namespace

Drupal\Tests\Core\Datetime

Code

private function createTimestamp($dateTimeString) {
  return \DateTime::createFromFormat('Y-m-d G:i:s', $dateTimeString)
    ->getTimestamp();
}