...

View Full Version : Time in military time?



helpplease
08-06-2002, 09:26 PM
How do I get the time in military time? Thanks for any help!
This is the code that I'm working with and I need it to be in military time:

<script LANGUAGE="JavaScript">
<!-- Begin
Stamp = new Date();
document.write('<span class="text">' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getYear() + '</span>&nbsp;');
var Hours;
var Mins;
var Secs;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " pm";
}
else {
Time = " am";
}
if (Hours > 12) {
Hours -= 12;
}
if (Hours == 0) {
Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;
}
Secs = Stamp.getSeconds();
if (Secs < 10) {
Secs = "0" + Secs;
}
document.write('<span class="text">' + Hours + ":" + Mins + ":" + Secs + Time + '</span>');// End -->
</script>

Thanks.

kansel
08-06-2002, 09:34 PM
Change this line

document.write('<span class="text">' + Hours + ":" + Mins + ":" + Secs + Time + '</span>');

to this

document.write('<span class="text">' + Stamp.getHours() + ":" + Mins + ":" + Secs + '</span>');

helpplease
08-06-2002, 09:39 PM
Thanks. Although, I feel like a moron now!! :o



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum