Converting Month Name to Month Number using PHP
by guruprasad[ Edit ] 2013-10-01 11:03:21
To Convert month name to month number,use the following
Example,
$monthname="Mar";
$monthnumber=date("m", strtotime($monthname));
echo $monthnumber;
It will print the month number.But At feb 28(or next day)and the months which does not have 31 days,will show wrong month,To avoid this, Use following,
Example,
$monthname="Mar";
$monthnumber=date("m", strtotime('1'.$monthname));
echo $monthnumber;
It will consider the monthname with prefix 1 with it.It Works For all months