Advertisement
Sk8erPeter

PHP: date functions' results related to the NEXT month /OUTP

Jun 18th, 2012
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // PHP: date functions' results related to the NEXT month are not correct
  3. // http://stackoverflow.com/questions/10834350/php-date-functions-results-related-to-the-next-month-are-not-correct-php-bugs
  4.  
  5. // RESULTS (OUTPUT) of http://pastebin.com/3iaH4iSZ
  6. // @see http://i.stack.imgur.com/mHHRu.png
  7.  
  8. strtotime('today');:
  9. 1338415200
  10.  
  11. strtotime('next month');:
  12. 1341147559
  13.  
  14. Current date as a MySQL-compatible timestamp [ date('Y-m-d H:i:s'); ]:
  15. '2012-05-31 14:59:19'
  16.  
  17. Get next month as a timestamp [ date('Y-m-d H:i:s', strtotime('next month')); ]:
  18. '2012-07-01 14:59:19'
  19.  
  20. 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'); ]:
  21. '2012-07-01 14:59:19'
  22.  
  23. Get last day of the current month/Get number of days in the current month [ date('t', strtotime('today')); ]:
  24. '31'
  25.  
  26. Get last day of the next month/Get number of days in the next month [ date('t', strtotime('next month')); ]:
  27. '31'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement