Connecting Tech Pros Worldwide Help | Site Map

month name predefined function?

  #1  
Old July 17th, 2005, 01:55 PM
laredotornado@zipmail.com
Guest
 
Posts: 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

  #2  
Old July 17th, 2005, 01:55 PM
Ewoud Dronkert
Guest
 
Posts: n/a

re: month name predefined function?


On 30 Apr 2005 08:43:06 -0700, laredotornado@zipmail.com wrote:[color=blue]
> the name of the month given the input of the month represented as a
> number between 1 and 12?[/color]

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/
  #3  
Old July 17th, 2005, 01:55 PM
johnjawed@gmail.com
Guest
 
Posts: n/a

re: month name predefined function?


I would just do it as this:

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

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 14th, 2005 04:15 AM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 13th, 2005 11:37 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 13th, 2005 09:56 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 13th, 2005 03:15 AM