By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,409 Members | 1,524 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,409 IT Pros & Developers. It's quick & easy.

month name predefined function?

P: n/a
Hello, I'm using PHP 4. Is there a predefined function for returning
the name of the month given the input of the month represented as a
number between 1 and 12?

Thanks, - Dave

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 30 Apr 2005 08:43:06 -0700, la***********@zipmail.com wrote:
the name of the month given the input of the month represented as a
number between 1 and 12?


Not easily, and only in English. You could use

echo date( 'F', mktime( 12, 0, 0, $month, 1, 2000, 0 ) );

(Use midday to avoid problems with daylight saving time).
Easier and less error prone would be

$monthname = array( 1 => 'January', 'February', 'March', <etc> );
echo $monthname[$month];
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #2

P: n/a
I would just do it as this:

<?PHP
$intMonth = 3; // March
printf("%s",date("M", mktime(0, 0, 0, $intMonth, 1, 2000));
?>

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.