Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-02-28 09:48:51
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,289
time script
could anybody help me edit this javascript to get it show time in 24 houres not in 12 with AM, PM?
<form name="Tick">
<input type="text" size="11" name="Clock">
</form>
<script>
<!--
/*By George Chiang (JK's JavaScript tutorial)
http://javascriptkit.com
Credit must stay intact for use*/
function show(){
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="AM"
if (hours>12){
dn="PM"
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
document.Tick.Clock.value=hours+":"+minutes+":"
+seconds+" "+dn
setTimeout("show()",1000)
}
show()
//-->
</script>
Offline
Re: time script
There are 24 hour clocks on the net which might be of help
Last edited by colak (2009-02-28 09:53:20)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: time script
Just leave out the section from the variable dn (which shows AM/PM), the part that corrects the hours from 24 hours to 12 hours and remove the dn (and space before it) in the line that displays the clock at the end:
<form name="Tick">
<input type="text" size="11" name="Clock">
</form>
<script type="text/javascript">
<!--
/*By George Chiang (JK's JavaScript tutorial)
http://javascriptkit.com
Credit must stay intact for use*/
function show(){
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
document.Tick.Clock.value=hours+":"+minutes+":"
+seconds
setTimeout("show()",1000)
}
show()
//-->
</script>
Last edited by jakob (2009-02-28 10:08:40)
TXP Builders – finely-crafted code, design and txp
Offline
Pages: 1