Jump to content

[SOLVED] CONVERT JANUARY INTO 01


alvinchua

Recommended Posts

i need HELP !

 

how to convert a month like

 

January in a combo box into a value ===> 01

Febuary in a combo box into a value  ===> 02

 

(this is because i am letting people to select the month as string in a combo box like Jan, Feb, March, bla bla... and later on i need to convert it into numeric to calculate days between two dates )

 

pls advice..

Link to comment
https://forums.phpfreaks.com/topic/88982-solved-convert-january-into-01/
Share on other sites

<script language="javascript">
var month="January";
switch(month) {
case "January":
var month="01";
break;
case "February":
var month="02";
break;
case "March":
var month="03";
break;
case "April":
var month="04";
break;
case "May":
var month="05";
break;
case "June":
var month="06";
break;
case "July":
var month="07";
break;
case "August":
var month="08";
break;
case "September":
var month="09";
break;
case "October":
var month="10";
break;
case "November":
var month="11";
break;
case "December":
var month="12";
break;
}
alert(month); // remove this - demo purposes only
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.