Same name and namespace in other branches
  1. 10 core/lib/Drupal.php \Drupal::time()
  2. 9 core/lib/Drupal.php \Drupal::time()

Returns the time service.

Return value

\Drupal\Component\Datetime\TimeInterface The time service.

9 calls to Drupal::time()
FilterDateTest::setUp in core/modules/datetime/tests/src/Functional/Views/FilterDateTest.php
Create nodes with relative dates of yesterday, today, and tomorrow.
Media::getRequestTime in core/modules/media/src/Entity/Media.php
ModeratedContentViewTest::testModeratedContentPage in core/modules/content_moderation/tests/src/Functional/ModeratedContentViewTest.php
Tests the moderated content page.
NodeCreationTest::testAuthoredDate in core/modules/node/tests/src/Functional/NodeCreationTest.php
Creates nodes with different authored dates.
ReplicaKillSwitchTest::testSystemInitIgnoresSecondaries in core/tests/Drupal/KernelTests/Core/Database/ReplicaKillSwitchTest.php
Tests database.replica_kill_switch service.

... See full list

File

core/lib/Drupal.php, line 775
Contains \Drupal.

Class

Drupal
Static Service Container wrapper.

Code

public static function time() {
  return static::getContainer()
    ->get('datetime.time');
}