Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

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

By: Sk8erPeter on Jun 18th, 2012  |  syntax: None  |  size: 1.04 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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'