Convert month number to month name

How can I convert month number into month date?

$Month = $getinfo2['Month'];

$Month is stored as 1-12, so that in the db January =1, February=2, etc.

How can I get the value of $Month not as a number but, as a name?
evibesmusicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Cornelia YoderArtistCommented:
$monthnamearray = array("January","February", ... ,"December");

$monthname = $monthnamearray[$monthnumber-1];

The minus 1 is because arrays are 0-indexed.
0
asafadisCommented:
A cleaner way of doing it:

$monthNumber = 8;
$monthName   = date("F", mktime(0, 0, 0, $monthNumber, 1, 2010));

Open in new window

0
Andyc75Software ArchitectCommented:
You can take advantage of php's date function for this.

Just build your month value into a string and extract the full month name.

no need to manage an array of month names.


$date = strtotime('2010/' . $Month . '/01');

$month_name = date("F",$date);

echo $month_name;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
evibesmusicAuthor Commented:
Like a glove my friend.  Perfect.  Thanks.
0
Cornelia YoderArtistCommented:
LOL@asafadis, if you think that is "cleaner" than what I posted.

@andyc75, that does exactly the same thing as mine, but mine does not rely on any external functions.

evibesmusic has chosen the solution s/he like the best, but I think dissing other Expert's ideas is really out of line for both of you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.