Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Standard time to Military onSubmit 1

Status
Not open for further replies.

venomdesign

Programmer
Apr 6, 2001
18
0
0
US
Is there a way to convert standard time into military time? Say someone inputs a time into a text box 2:35, on the submission it will convert that to 14:35 and send that value to the database. Thanks in advance for any help.
 
VenomDesign,

Yes, this is very possible. However, I'm getting the impression that you're looking for someone to write this for you... ;)

- DB Web Developer
Digital Video Arts, LTD.
 
Hi venomdesign,

Try this sample:

<script language=&quot;javascript&quot;>
function militaryTime(myItem) {
var myValue, myArray, myHour;
myValue = &quot;&quot; + myItem.value;
myArray = myValue.split(&quot;:&quot;);
myHour = parseInt(myArray[0], 10);
switch (myHour) {
case 1: myArray[0] = 13;
break;
case 2: myArray[0] = 14;
break;
case 3: myArray[0] = 15;
break;
case 4: myArray[0] = 16;
break;
case 5: myArray[0] = 17;
break;
case 6: myArray[0] = 18;
break;
case 7: myArray[0] = 19;
break;
case 8: myArray[0] = 20;
break;
case 9: myArray[0] = 21;
break;
case 10: myArray[0] = 22;
break;
case 11: myArray[0] = 23;
break;
case 12: myArray[0] = 24;
break;
};
alert(myArray[0] + &quot;:&quot; + myArray[1]);
};
</script>

Hope this helps....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top