954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Month conversion to its numerical equivalent

how to convert Month in words to its numeric equivalent....
example:

<?php
$month = 'JANUARY';

// code to convert the month JANUARY to its numerical equivalent...

echo 'help please for the numerical JANUARY equivalent here';

?>

-----------------------------
SAMPLE OUTPUT

01

lloydsbackyard
Light Poster
34 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

Try the date_parse function.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

Try this

<?php
$month = 'JANUARY';

echo $mon = date('m',strtotime($month));
?>
Karthik_pranas
Posting Pro
564 posts since Feb 2011
Reputation Points: 96
Solved Threads: 97
 

and when inputting the date,
If you have control of the data form
<select><option value='1'>January</option><option value='2'>February</option> etc

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

thanks...it helps...i got this code...from it

$month = strtoupper($_POST['month']);
$conmonth = strtotime($month);
$new_month=idate('m', $conmonth);

lloydsbackyard
Light Poster
34 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

if your problem solvec mark this thread as solved

Karthik_pranas
Posting Pro
564 posts since Feb 2011
Reputation Points: 96
Solved Threads: 97
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: