function DateTest::createTimestamp

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Datetime/DateTest.php \Drupal\Tests\Core\Datetime\DateTest::createTimestamp()
  2. 8.9.x core/tests/Drupal/Tests/Core/Datetime/DateTest.php \Drupal\Tests\Core\Datetime\DateTest::createTimestamp()
  3. 11.x core/tests/Drupal/Tests/Core/Datetime/DateTest.php \Drupal\Tests\Core\Datetime\DateTest::createTimestamp()

Creates a UNIX timestamp given a date and time string.

Parameters

string $dateTimeString: The formatted date and time string. The format is year-month-day hour:minute:seconds (e.g. 2013-12-11 10:09:08).

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 458

Class

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

Namespace

Drupal\Tests\Core\Datetime

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.