I have two dates, formated like "Y-m-d H:i:s". I need to compare these two dates and figure out the hour difference.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
As an addition to accepted answer I would like to remind that
\DateTime::diff
is available!\DateInterval
documentation.You can use DateTime interface also -
This is because of day time saving. Daylight Saving Time (United States) 2014 began at 2:00 AM on Sunday, March 9.
You lose one hour during the period from $date1 = "2014-03-07 05:49:23" to $date2 = "2014-03-14 05:49:23";