Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get seconds elapsed since midnight

Tags:

Using PHP how do you get the number of seconds elapsed since midnight of the current day?

All i've tried right now is:

$hour=substr(date("h:i:s"),0,2); $minute=substr(date("h:i:s"),3,2); echo $hour."\r\n"; echo $minute."\r\n"; 

...but it doesn't return the correct server time of the response and I don't know how to do that.

like image 693
Nubcake Avatar asked Jul 13 '12 01:07

Nubcake


1 Answers

This should work.

echo time() - strtotime("today"); 

This will only show your servers timezone though.

like image 53
noko Avatar answered Oct 06 '22 22:10

noko