
PHP: date functions' results related to the NEXT month /OUTP
By:
Sk8erPeter on
Jun 18th, 2012 | syntax:
None | size: 1.04 KB | hits: 23 | expires: Never
// PHP: date functions' results related to the NEXT month are not correct
// http://stackoverflow.com/questions/10834350/php-date-functions-results-related-to-the-next-month-are-not-correct-php-bugs
// RESULTS (OUTPUT) of http://pastebin.com/3iaH4iSZ
// @see http://i.stack.imgur.com/mHHRu.png
strtotime('today');:
1338415200
strtotime('next month');:
1341147559
Current date as a MySQL-compatible timestamp [ date('Y-m-d H:i:s'); ]:
'2012-05-31 14:59:19'
Get next month as a timestamp [ date('Y-m-d H:i:s', strtotime('next month')); ]:
'2012-07-01 14:59:19'
Get last day of the next month as a timestamp with DateTime class [ $dateObj->add(new DateInterval('P1M')); $dateObj->format('Y-m-d H:i:s'); ]:
'2012-07-01 14:59:19'
Get last day of the current month/Get number of days in the current month [ date('t', strtotime('today')); ]:
'31'
Get last day of the next month/Get number of days in the next month [ date('t', strtotime('next month')); ]:
'31'