Connecting Tech Pros Worldwide Help | Site Map

month name predefined function?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 12:55 PM
laredotornado@zipmail.com
Guest
 
Posts: n/a
Default month name predefined function?

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, 12:55 PM
Ewoud Dronkert
Guest
 
Posts: n/a
Default 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, 12:55 PM
johnjawed@gmail.com
Guest
 
Posts: n/a
Default 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));
?>

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.