public function FrozenTime::getCurrentMicroTime in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 8.2 tests/modules/frozenintime/src/FrozenTime.php \Drupal\frozenintime\FrozenTime::getCurrentMicroTime()
- 4.0.x tests/modules/frozenintime/src/FrozenTime.php \Drupal\frozenintime\FrozenTime::getCurrentMicroTime()
- 3.0.x tests/modules/frozenintime/src/FrozenTime.php \Drupal\frozenintime\FrozenTime::getCurrentMicroTime()
- 3.1.x tests/modules/frozenintime/src/FrozenTime.php \Drupal\frozenintime\FrozenTime::getCurrentMicroTime()
- 3.2.x tests/modules/frozenintime/src/FrozenTime.php \Drupal\frozenintime\FrozenTime::getCurrentMicroTime()
- 3.3.x tests/modules/frozenintime/src/FrozenTime.php \Drupal\frozenintime\FrozenTime::getCurrentMicroTime()
- 3.4.x tests/modules/frozenintime/src/FrozenTime.php \Drupal\frozenintime\FrozenTime::getCurrentMicroTime()
- 3.5.x tests/modules/frozenintime/src/FrozenTime.php \Drupal\frozenintime\FrozenTime::getCurrentMicroTime()
- 3.6.x tests/modules/frozenintime/src/FrozenTime.php \Drupal\frozenintime\FrozenTime::getCurrentMicroTime()
- 3.7.x tests/modules/frozenintime/src/FrozenTime.php \Drupal\frozenintime\FrozenTime::getCurrentMicroTime()
Returns the current system time with microsecond precision.
This method should be used to obtain the current system time, with microsecond precision, at the time the method was called.
This method can replace many instances of
$microtime = microtime();
$microtime = microtime(TRUE);
with
$request_time = \Drupal::time()
->getCurrentMicroTime();
or the equivalent using the injected service.
This method should only be used when the current system time is actually needed, such as with timers or time interval calculations. If only the time at the start of the request and microsecond precision is needed, use TimeInterface::getRequestMicroTime().
Using the time service, rather than other methods, is especially important when creating tests, which require predictable timestamps.
Return value
float A Unix timestamp with a fractional portion.
Overrides TimeInterface::getCurrentMicroTime
See also
\Drupal\Component\Datetime\TimeInterface::getRequestTime()
\Drupal\Component\Datetime\TimeInterface::getRequestMicroTime()
\Drupal\Component\Datetime\TimeInterface::getCurrentTime()
File
- tests/
modules/ frozenintime/ src/ FrozenTime.php, line 40
Class
- FrozenTime
- Time implementation were time is frozen
Namespace
Drupal\frozenintimeCode
public function getCurrentMicroTime() {
return static::MY_BIRTHDAY;
}