I create an object
$date = new DateTime();
It is set to current date 2011-04-01 21:43:40. I try the following
$date->modify('midnight');
I expect the object to set to 2011-04-01 00:00:00. But nothing happened. Object hadn't beed modified, and continue to have a 2011-04-01 21:43:40 date. I just want to reset the time to midnight (00:00:oo).
Best Answer
http://codepad.org/w5RAF0Lh
This piece of code (with midnight) will not work without date.timezone setting
UPDATE: this piece of code requires PHP 5.3.6 to work correctly. In previous versions
DateTime::modify('midnight')
didn't work