PHP date operation summary recently, PHP date processing has been applied in many projects, which can be recorded by the way .? & Lt ;? Php // PHP obtain the echodate ('Y-m-D', time ()-86400) of the day before and after the current date; echodate ('Y-m-D ', time () + 86400) PHP date operation summary
There are many PHP date processing applications in recent projects, which should be recorded by the way.
?
* [1] => 2011-07-10 *) * // Shard line ------------------------------------- // PHP obtains the function getMonthDay ($ date) on the first and last days of the month of the specified date) {$ firstday = date ("Y-m-01", strtotime ($ date); $ lastday = date ("Y-m-d ", strtotime ("$ firstday + 1 month-1 day"); return array ($ firstday, $ lastday);} print_r (getMonthDay ("2011-07-10 ")); /*** Array * (* [0] => 2011-07-01 * [1] => 2011-07-31 *)*/
// PHP returns the two-date interval days [PHP version> = 5.3 Valid] function getIntervalDay ($ date1 = null, $ date2 = null) {$ datetime1 = new DateTime ($ date1 ); $ datetime2 = new DateTime ($ date2); $ interval = $ datetime1-> diff ($ datetime2); return $ interval-> format ('% ');} function getIntervalDay1 ($ date1 = null, $ date2 = null) {$ datetime1 = date_create ($ date1); $ datetime2 = date_create ($ date2); $ interval = date_diff ($ datetime1, $ datetime2); return $ I Nterval-> format ('% A');} echo getIntervalDay ('2017-07-25', '2017-07-26 '); // 1 echo getIntervalDay1 ('2017-07-25 ', '2017-08-28 '); // 34?>??
?