I need to display the time but it must start from 00:00:00? I\'ve got the following but it uses the current time.
print(date(\"H:i:s\"));
Use mktime()
if you want to start with midnight for the current date:
OUTPUTS
Friday 14th of October 2011 12:00:00 AM
http://codepad.org/s2NrVfRq
In mktime(), you pass arguments for hours, minutes, seconds, month, day, year
, so set hours, minutes, seconds
to 0
to get today at midnight
. (Note, as Phil points out, mktime()
's arguments are optional and you can leave month, day, year
out and it will default to the current date).
The mktime()
function returns a unix timestamp representing the number of seconds since the unix epoch (January 1, 1970). You can count up from it in seconds or multiples of seconds.
OUTPUTS
Friday 14th of October 2011 12:00:00 AM
Friday 14th of October 2011 12:01:00 AM
Friday 14th of October 2011 01:00:00 AM
http://codepad.org/FTr98z1n