unix timestamp round to midnight unix timestamp round to midnight php php

unix timestamp round to midnight


echo date('d-m-Y H:i:s', strtotime('today', 1324189035));


Because of how you're using it, I wouldn't calculate midnight at all: it is far easier to simply convert what you're adding to the timestamp into 24 hour time and then use strtotime:

echo strtotime("0:00",1324189035); // 1324184400echo strtotime("17:50",1324189035); // 1324248600

And if you want to have that in human readable, use date and m/d/Y H:i:s:

echo date('m/d/Y H:i:s', strtotime('17:50',1324189035)); // 12/18/2011 17:50:00


Simply Use

strtotime('today midnight');