PHP gets 00:00:00 unix timestamp
2 answers
An alternative method to get the same result ... Unix time is the number of seconds since 1970-01-01 00:00:00 UTC, so every whole day is a multiple of (60 * 60 * 24) seconds.
Using this fact, you can use the modulus (%) to calculate and then remove the remainder (i.e. seconds, hours, and minutes) from the day and go back to the first hours!
date_default_timezone_set('UTC');
$that_date = 1407050129;
$first_hour = $that_date - ($that_date % (60*60*24));
print date('Y-m-d H:i:s', strval($first_hour));
// 2014-08-03 00:00:00
+2
source to share