GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Jun-2007, 04:53
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 741
admin will become famous soon enough

Converting month number to month name


How do you convert a month number, e.g. 02, into month name, i.e. February?

For the moment, I have this in my PHP script:

PHP Code:

// convert month number to month name.
$month_name = date( 'F', mktime(0, 0, 0, $month_number) );

// Result:
// $month_name == "February"; 



It works, but I was wondering if there is something else already available that I am not aware of.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #2  
Old 14-Jun-2007, 08:56
TurboPT's Avatar
TurboPT TurboPT is offline
Regular Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 926
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Converting month number to month name


That seems, so far, about the easiest way to get it done.

Not sure if you have that in a function, but here's a code snippet that does:
http://www.phpit.net/code/get-month-name/
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #3  
Old 14-Jun-2007, 22:24
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 741
admin will become famous soon enough

Re: Converting month number to month name


I think it's overkill to write a whole function for something that's just one line long, and for something I have a use for only once, and in a loop.

It was a 'design flaw', the text file that holds the data for the gid_archive.php page only contains numeric month & year data. It should have been unix timestamps.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #4  
Old 15-Jun-2007, 07:39
TurboPT's Avatar
TurboPT TurboPT is offline
Regular Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 926
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Converting month number to month name


Your right, one liner, used once -- no function needed!
(just didn't know the scope of use)
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #5  
Old 15-Jun-2007, 07:55
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 741
admin will become famous soon enough

Re: Converting month number to month name


But thank you for confirming that this is the best way to get the information, at least I can move on to other things instead of wasting my time searching for a better solution that isn't there. I can be obsessive sometimes
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
 
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please Help Me To Build My Calendar!!! suriacute85 Java Forum 0 05-Oct-2006 19:39
Converting a number amount to text Godzilla CPP / C++ Forum 5 31-Mar-2006 11:38
C++ Program Print Calendar HELP tones1986 CPP / C++ Forum 2 08-Sep-2005 21:05
Anyone can write a program code for this??? chriskan76 C Programming Language 1 19-Oct-2004 20:25

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:33.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.