I have been trying to work out how to get the exact time to the second until a certain day and hour. I believe it is开发者_运维知识库 the time
function in php but i cant seem to get my head around it.
I am trying to spit it out in the following format 'dd:hh:mm:ss'
Thanks
You can use datediff for that http://www.php.net/manual/en/datetime.diff.php, and the following is how you use date to format it the way you want
http://php.net/date echo date("d:H:i:s");
EDIT:
if your php version doesn't permit, you could use:
function datediff($date) {
return strtotime($date) - time();
}
echo datediff("2011-12-31 15:00");
echo date('d:H:i:s', mktime($hour, $minute, $second, $month, $day, $year));
Where mktime()
returns a timestamp.
精彩评论