note 56376 added to function.date
| From: | TD at osu1 dot php dot net | Date: | Wed, 31 Aug 2005 23:11:00 +0000 |
| Subject: | note 56376 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94554@lists.php.net to get a copy of this message | ||
I was having trouble with the following code:
<?php
echo "Next month: " . date("F", strtotime("+1 month"));
?>
For some reason, today (august 31st), this was outputting: "Next month: October".
I can't figure out why, so here's my hack.
<?php
echo "Next month: " . month_to_hr(date("n"));
function month_to_hr($monthnum) {
switch ($monthnum) {
case 1: return "January"; break;
case 2: return "February"; break;
case 3: return "March"; break;
case 4: return "April"; break;
case 5: return "May"; break;
case 6: return "June"; break;
case 7: return "July"; break;
case 8: return "August"; break;
case 9: return "September"; break;
case 10: return "October"; break;
case 11: return "November"; break;
case 12: return "December"; break;
case default: return "Unknown"; break;
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56376
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56376&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56376&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56376&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56376&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56376&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56376&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56376&report=yes
Search -- http://master.php.net/manage/user-notes.php