note 75472 added to function.strtotime
| From: | (youfixit) | Date: | Thu, 31 May 2007 22:03:41 +0000 |
| Subject: | note 75472 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127089@lists.php.net to get a copy of this message | ||
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?
----
Server IP: 69.39.81.135
Probable Submitter: 170.35.224.64
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/75472
Del: integrated -- https://master.php.net/note/delete/75472/integrated
Del: useless -- https://master.php.net/note/delete/75472/useless
Del: bad code -- https://master.php.net/note/delete/75472/bad+code
Del: spam -- https://master.php.net/note/delete/75472/spam
Del: non-english -- https://master.php.net/note/delete/75472/non-english
Del: in docs -- https://master.php.net/note/delete/75472/in+docs
Del: other reasons-- https://master.php.net/note/delete/75472
Reject -- https://master.php.net/note/reject/75472
Search -- https://master.php.net/manage/user-notes.php