I have the following line of code:
round(microtime(true) * 1000)
to get the timestamp in milliseconds of the current time. I need to pick up a future date, example, 10 or 5 minutes ahead. How can I do this?
I have the following line of code:
round(microtime(true) * 1000)
to get the timestamp in milliseconds of the current time. I need to pick up a future date, example, 10 or 5 minutes ahead. How can I do this?
One option is to use the function DateTime::add
:
$dataQualquer = new DateTime();
$dataQualquer->add(new DateInterval('PT10M')); // 10 minutos no futuro
echo 'Timestamp:'.$dataQualquer->getTimestamp();
You can use time
of PHP, which returns the team in seconds.
<?php
// time atual em segundos
$now = time();
// adicionando 5 minutos
$futuro5min = $now + (5*60);
// adicionando 10 minutos
$futuro = $now + (10*60);
?>
Remembering that the timestamp is in seconds. To get in milliseconds, simply multiply the final result by 1000.