How to choose date in timestamp

0

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?

    
asked by anonymous 15.08.2016 / 20:34

2 answers

2

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();
    
15.08.2016 / 20:57
2

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.

link

    
15.08.2016 / 21:00