Link to home
Start Free TrialLog in
Avatar of Zambian4eva
Zambian4eva

asked on

Formatting Dates example 01 - January

I am trying to convert a two digit Month (01,02 etc...) to (January, February etc..)

This is what I have, but it doesn't work:

$month = "02";
$date = strtotime($month);
$New_Month = date("F",$date);

Can anyone help? Thanks
Avatar of snoyes_jw
snoyes_jw
Flag of United States of America image

change your middle line to something like

$date = strtotime($month . "/01/01");
ASKER CERTIFIED SOLUTION
Avatar of crazycomputers
crazycomputers

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of noy_ipunk
noy_ipunk

Well, I would do it with smt like this :

$mth = 14;  //for example..skips december and go back to january

//you must fill in all the arguments if you want to make use of date function ;)
$month = date("F", mktime(0, 0, 0, $mth+1 , 0 ,0));  //plus 1 because month's array starts from 0

echo "month number is= $mth and month name is  $month ";

//result will be : month number is= 14 and month name is February