<head>
<script type="text/javascript">
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t=setTimeout('startTime()',500)
}
function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
</script>
</head>
<b>
<body onload="startTime()">
<div id="txt"><b>$vbphrase[loading_clock]</b></div>
</body></b>
Then: Import The Product
History
- V.1.0 Released
Future Developments
- Cache Template
I Will Only Give Support To Those That Click Install
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
I have tried your modified version and it looks great. Did notice from 12pm to 1pm the clock showed AM and switch to PM when the clock rolled to 1pm. Any suggestions?
there's small silly mistake, you just need to make a small change
Replace the following line
Code:
if (h > 12)
with
Code:
if (h >= 12)
Quote:
Originally Posted by Alibass;
Works good on 3.6.7PL1, but when viewing thread the clock constantly shows Loading Clock.....
Here's the fixed version of it
replace what you have before with this
Code:
<b><div id="txt"><b>$vbphrase[loading_clock]</b></div></b>
<script type="text/javascript">
function startTime()
{
var today = new Date()
var h = today.getHours()
var m = today.getMinutes()
var s = today.getSeconds()
var day = today.getDay()
var date = today.getDate()
var month = today.getMonth()
var year = today.getFullYear()
var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var months = new Array(" January"," February"," March"," April"," May"," June"," July"," August"," September"," October"," November"," December")
var am_pm
if (h >= 12) {
h -= 12
am_pm = "P.M."
}
else {
am_pm ="A.M."
}
// add a zero in front of numbers<10
m = checkTime(m)
s = checkTime(s)
h = checkTime(h)
document.getElementById('txt').innerHTML = days[day] + " " + date + months[month] + " " + year + ", " + h + ":" + m + ":" + s + " " + am_pm
setTimeout("startTime()", 1000)
}
function checkTime(i)
{
if (i < 10)
{i = "0" + i}
return i
}
startTime()
</script>
Actually your code is for a 24 hour clock and works best that way. If you try and use it as a 12 hour clock then midnight is shown as 00:00:00 AM instead on 12:00:00 AM and noon is shown 00:00:00 PM instead of 12:00:00 PM
Find
Code:
if (h >= 12) {
h -= 12
am_pm = "P.M."
}
else {
am_pm = "A.M."
}
Replace (for 24 hour clock)
Code:
if (h >= 12) {
h <= 12
am_pm = ""
}
else {
am_pm = ""
}
Actually your code is for a 24 hour clock and works best that way. If you try and use it as a 12 hour clock then midnight is shown as 00:00:00 AM instead on 12:00:00 AM and noon is shown 00:00:00 PM instead of 12:00:00 PM
Find
Code:
if (h >= 12) {
h -= 12
am_pm = "P.M."
}
else {
am_pm = "A.M."
}
Replace (for 24 hour clock)
Code:
if (h >= 12) {
h <= 12
am_pm = ""
}
else {
am_pm = ""
}