Frage

Calculating future date from seconds.

$var = 5183990; //seconds
$today = '2013-02-16 11:00:00'; //date

like I have 5183990 seconds as a variable $var.
Now I want to know future date/time after 5183990 seconds from current time.

War es hilfreich?

Lösung

Since time() returns the current timestamp in seconds, just add your interval in seconds to it, then format it as a date:

echo date("Y-m-d H:i:s",time()+$var);

Andere Tipps

Try this

strtotime('2013-02-16 11:00:00')-time()+$var;

details : http://php.net/manual/en/function.strtotime.php

You can use,

echo date("Y m d h:i:s a",time()+$var);

where,

time() returns the current time then add the seconds in $var it will produce the time after $var seconds....the date() then formats that to your choice...

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top