views:

95

answers:

2

In PHP 5.2, how to get the last second in a day? time() + 86400 gets the next Day only?

+10  A: 
echo date('r', strtotime('tomorrow') - 1);

returns 'Mon, 18 Jan 2010 23:59:59'

you need that deal with leap seconds (times such as 23:59:60)

jspcal
+1 for leap seconds
Thilo
Leap second has no relevance here. For example, "2008-12-31 23:59:60" is the same as "2009-01-01 00:00:00". Quoting http://unix-time.com/ : "The Unix time number increases by exactly 86400 each day, regardless of how long the day is." and "When a leap second is inserted...the Unix time number increases continuously during the leap second...and then jumps down by 1 at the end of the leap second, which is the start of the next day."
GZipp
GZipp, so you mean that my solution is also correct? :D Nice to learn about leap seconds though, I didn't know them earlier.
Emil Vikström
+5  A: 
strtotime('23:59:59');
Emil Vikström