note 75472 rejected from function.strtotime by nlopess
| From: | nlopess@php.net | Date: | Tue, 19 Jun 2007 12:18:16 +0000 |
| Subject: | note 75472 rejected from function.strtotime by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127742@lists.php.net to get a copy of this message | ||
Note Submitter: aquaonegmailcom(youfixit)
----
something is very screwed up here in 5.1.6
<?php
$year = 2007;
$days31 = array( 1, 3, 5, 7, 8, 10, 12 );
$days30 = array( 4, 6, 9, 11 );
print( "monthNumber, lastDay: prevMonth, currMonth, nextMonth<br />\n" );
for( $monthNumber=1; $monthNumber < 13; $monthNumber++ ) {
if( in_array( $monthNumber, $days31 )) { $lastDay = 31; }
elseif( in_array( $monthNumber, $days30 )) { $lastDay = 30; }
else { $lastDay = 28; }
$currMonth = date( 'M', strtotime( "$monthNumber/$lastDay/$year" ));
$prevMonth = date( 'M', strtotime( '-1 month', strtotime(
"$monthNumber/$lastDay/$year" )));
$nextMonth = date( 'M', strtotime( '+1 month', strtotime(
"$monthNumber/$lastDay/$year" )));
printf( "month %d, %d/%d/%d: %s, %s, %s<br />\n", $monthNumber, $monthNumber,
$lastDay, $year, $prevMonth, $currMonth, $nextMonth );
}
?>
gives you
monthNumber, lastDay: prevMonth, currMonth, nextMonth
month 1, 1/31/2007: Dec, Jan, Mar
month 2, 2/28/2007: Jan, Feb, Mar
month 3, 3/31/2007: Mar, Mar, May
month 4, 4/30/2007: Mar, Apr, May
month 5, 5/31/2007: May, May, Jul
month 6, 6/30/2007: May, Jun, Jul
month 7, 7/31/2007: Jul, Jul, Aug
month 8, 8/31/2007: Jul, Aug, Oct
month 9, 9/30/2007: Aug, Sep, Oct
month 10, 10/31/2007: Oct, Oct, Dec
month 11, 11/30/2007: Oct, Nov, Dec
month 12, 12/31/2007: Dec, Dec, Jan
O_o
tacking on 00:00:00 to the dates doesn't change the behavior. it's just...
"wrong"
anyone else encountered this? workaround?