Post by Mithras on Jul 28, 2006 17:08:30 GMT -8
Ok, ya, the title pretty much says it all. This clock has an adjustable speed, and is the same regardless of the timezone. Just edit the indicated parts. Place this wherever you want the clock to appear.
<script type="text/javascript">
// Clock With Adjustable Speed by Mithras
// Do not repost -- this header must remain in tact.
var startTime = new Date()
var TimeNow = new Date()
var clockTime = new Date()
var elapsedTime = new Date()
var totalMilliseconds
var speed
var TimeZone
var label
var twoDigitYear
var clockAlign
var clockColor
var timezoneoffset = TimeNow.getTimezoneOffset()
// Edit below
// Clock start time:
startTime.setFullYear('2006')
startTime.setMonth('6')
startTime.setDate('28')
startTime.setHours('19') // Note: Hours is in 24 hour format
startTime.setMinutes('41')
startTime.setSeconds('0')
// Other clock function settings:
speed = 2
TimeZone = -4 // This will have to be changed according to Daylight Savings Time.
// Clock apperance settings:
clockAlign = 'center'
clockColor = 'black'
// Do not edit below
TimeNow.setTime(TimeNow.getTime() + timezoneoffset*60*1000);
TimeNow.setTime(TimeNow.getTime() + TimeZone*60*60*1000);
totalMilliseconds = ((TimeNow.getFullYear() - startTime.getFullYear()) * 365 * 24 * 60 * 60 * 1000)
totalMilliseconds += ((TimeNow.getMonth() - startTime.getMonth()) * 12 * 24 * 60 * 60 * 1000)
totalMilliseconds += ((TimeNow.getDate() - startTime.getDate()) * 24 * 60 * 60 * 1000)
totalMilliseconds += ((TimeNow.getHours() - startTime.getHours()) * 60 * 60 * 1000)
totalMilliseconds += ((TimeNow.getMinutes() - startTime.getMinutes()) * 60 * 1000)
totalMilliseconds += ((TimeNow.getSeconds() - startTime.getSeconds()) * 1000)
totalMilliseconds = totalMilliseconds * speed
elapsedTime.setFullYear(Math.floor(totalMilliseconds / 1000 / 60 / 60 / 24 / 365))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 1000 / 60 / 60 / 24 / 365)
clockTime.setFullYear(elapsedTime.getFullYear() + startTime.getFullYear())
elapsedTime.setMonth(Math.floor(totalMilliseconds / 1000 / 60 / 60 / 24 / 12))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 1000 / 60 / 60 / 24 / 12)
clockTime.setMonth(elapsedTime.getMonth() + startTime.getMonth())
clockTime.setMonth(clockTime.getMonth() + 1)
elapsedTime.setDate(Math.floor(totalMilliseconds / 1000 / 60 / 60 / 24))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 100 / 60 / 60 / 24)
clockTime.setDate(elapsedTime.getDate() + startTime.getDate())
elapsedTime.setHours(Math.floor(totalMilliseconds / 1000 / 60 / 60))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 1000 / 60 / 60)
clockTime.setHours(elapsedTime.getHours() + startTime.getHours())
if(clockTime.getHours() < 12 || clockTime.getHours() == 24)
label = 'AM'
else {
label = 'PM'
clockTime.setHours(clockTime.getHours() - 12)
}
elapsedTime.setMinutes(Math.floor(totalMilliseconds / 1000 / 60))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 1000 / 60)
clockTime.setMinutes(elapsedTime.getMinutes() + startTime.getMinutes())
elapsedTime.setSeconds(Math.floor(totalMilliseconds / 1000))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 1000)
clockTime.setSeconds(elapsedTime.getSeconds() + startTime.getSeconds())
document.write('<div align="' + clockAlign + '">')
document.write('<font color="' + clockColor + '">')
document.write(clockTime.getHours() + ':')
if(clockTime.getMinutes() < 10) {
document.write('0' + clockTime.getMinutes() + ':')
}
else {
document.write(clockTime.getMinutes() + ':')
}
if(clockTime.getSeconds() < 10) {
document.write('0' + clockTime.getSeconds() + ' ')
} else {
document.write(clockTime.getSeconds() + ' ')
}
document.write(label + ' -- ')
document.write(clockTime.getMonth() + '/')
document.write(clockTime.getDate() + '/')
document.write(clockTime.getFullYear() + ' ')
document.write('</font></div>')
</script>
<script type="text/javascript">
// Clock With Adjustable Speed by Mithras
// Do not repost -- this header must remain in tact.
var startTime = new Date()
var TimeNow = new Date()
var clockTime = new Date()
var elapsedTime = new Date()
var totalMilliseconds
var speed
var TimeZone
var label
var twoDigitYear
var clockAlign
var clockColor
var timezoneoffset = TimeNow.getTimezoneOffset()
// Edit below
// Clock start time:
startTime.setFullYear('2006')
startTime.setMonth('6')
startTime.setDate('28')
startTime.setHours('19') // Note: Hours is in 24 hour format
startTime.setMinutes('41')
startTime.setSeconds('0')
// Other clock function settings:
speed = 2
TimeZone = -4 // This will have to be changed according to Daylight Savings Time.
// Clock apperance settings:
clockAlign = 'center'
clockColor = 'black'
// Do not edit below
TimeNow.setTime(TimeNow.getTime() + timezoneoffset*60*1000);
TimeNow.setTime(TimeNow.getTime() + TimeZone*60*60*1000);
totalMilliseconds = ((TimeNow.getFullYear() - startTime.getFullYear()) * 365 * 24 * 60 * 60 * 1000)
totalMilliseconds += ((TimeNow.getMonth() - startTime.getMonth()) * 12 * 24 * 60 * 60 * 1000)
totalMilliseconds += ((TimeNow.getDate() - startTime.getDate()) * 24 * 60 * 60 * 1000)
totalMilliseconds += ((TimeNow.getHours() - startTime.getHours()) * 60 * 60 * 1000)
totalMilliseconds += ((TimeNow.getMinutes() - startTime.getMinutes()) * 60 * 1000)
totalMilliseconds += ((TimeNow.getSeconds() - startTime.getSeconds()) * 1000)
totalMilliseconds = totalMilliseconds * speed
elapsedTime.setFullYear(Math.floor(totalMilliseconds / 1000 / 60 / 60 / 24 / 365))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 1000 / 60 / 60 / 24 / 365)
clockTime.setFullYear(elapsedTime.getFullYear() + startTime.getFullYear())
elapsedTime.setMonth(Math.floor(totalMilliseconds / 1000 / 60 / 60 / 24 / 12))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 1000 / 60 / 60 / 24 / 12)
clockTime.setMonth(elapsedTime.getMonth() + startTime.getMonth())
clockTime.setMonth(clockTime.getMonth() + 1)
elapsedTime.setDate(Math.floor(totalMilliseconds / 1000 / 60 / 60 / 24))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 100 / 60 / 60 / 24)
clockTime.setDate(elapsedTime.getDate() + startTime.getDate())
elapsedTime.setHours(Math.floor(totalMilliseconds / 1000 / 60 / 60))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 1000 / 60 / 60)
clockTime.setHours(elapsedTime.getHours() + startTime.getHours())
if(clockTime.getHours() < 12 || clockTime.getHours() == 24)
label = 'AM'
else {
label = 'PM'
clockTime.setHours(clockTime.getHours() - 12)
}
elapsedTime.setMinutes(Math.floor(totalMilliseconds / 1000 / 60))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 1000 / 60)
clockTime.setMinutes(elapsedTime.getMinutes() + startTime.getMinutes())
elapsedTime.setSeconds(Math.floor(totalMilliseconds / 1000))
totalMilliseconds = totalMilliseconds - Math.floor(totalMilliseconds / 1000)
clockTime.setSeconds(elapsedTime.getSeconds() + startTime.getSeconds())
document.write('<div align="' + clockAlign + '">')
document.write('<font color="' + clockColor + '">')
document.write(clockTime.getHours() + ':')
if(clockTime.getMinutes() < 10) {
document.write('0' + clockTime.getMinutes() + ':')
}
else {
document.write(clockTime.getMinutes() + ':')
}
if(clockTime.getSeconds() < 10) {
document.write('0' + clockTime.getSeconds() + ' ')
} else {
document.write(clockTime.getSeconds() + ' ')
}
document.write(label + ' -- ')
document.write(clockTime.getMonth() + '/')
document.write(clockTime.getDate() + '/')
document.write(clockTime.getFullYear() + ' ')
document.write('</font></div>')
</script>