質問

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.

役に立ちましたか?

解決

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);

他のヒント

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...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top