note 55796 added to function.date
| From: | InterNic at osu1 dot php dot net | Date: | Sat, 13 Aug 2005 12:31:18 +0000 |
| Subject: | note 55796 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93555@lists.php.net to get a copy of this message | ||
If you need to convert the "short textual representation of a month, three letters" to
"Numeric representation of a month, with leading zeros" for some reason, here is a simple
function to do that:
<?
function monthNumber($month) {
$months = array(1 => 'Jan', 'Feb', 'Mar', 'Apr',
'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec');
for ($i = 1; $i < 13; $i++) {
if ($month == $months[$i]) {
if ($i < 10) $num = "0" . $i;
else $num = $i;
}
}
if (!$num) return false;
return $num;
}
echo monthNumber("Jan");
?>
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55796
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55796&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55796&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55796&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55796&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55796&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55796&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55796&report=yes
Search -- http://master.php.net/manage/user-notes.php