Ninjagranny
11-21-2003, 06:34 PM
Must be the day for them
I am trying to work out where
getDate() gets its time from - it seems to ignore my local system time .
get UTCDate() I assume gets its time from the net .
I have set my local timezone to australia as I am in GMT at present anyway - but the following code ( hope its not me being silly ) returns 0 value
- I know this doesnt look important but Im trying to understand how things work and am about to punch monitor :(
Long code snippet sorry
function clock() {
var date = new Date()
var year = date.getUTCFullYear()
var month = date.getUTCMonth()
var day = date.getUTCDate()
var hour = date.getUTCHours()
var minute = date.getUTCMinutes()
var second = date.getUTCSeconds()
var months = new Array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC")
var monthname = months[month]
if (minute < 10) {
minute = "0" + minute
}
if (second < 10) {
second = "0" + second
}
var ldate = new Date()
var lyear = ldate.getFullYear()
var lmonth = ldate.getMonth()+1
var lday = ldate.getDate()
var lhour = ldate.getHours()
var lminute = ldate.getMinutes()
var lsecond = ldate.getSeconds()
if (lminute < 10) {
lminute = "0" + lminute
}
if (lsecond < 10) {
lsecond = "0" + lsecond
}
document.title = greeting () +" " + day + appd()+ monthname + ", " + year + " " + hour + ":" + minute + ":" + second+ "
GMT"+" Your time "+" " + lday +" "+ lmonth + ", " + lyear + " " + lhour + ":" + lminute + ":" + lsecond
window.status = greeting () +" " + day + appd()+ monthname + ", " + year + " " + hour + ":" + minute + ":" + second + "
GMT"+" Your time "+" " + lday +" "+ lmonth + ", " + lyear + " " + lhour + ":" + lminute + ":" + lsecond
document.countdown.counter.value =greeting () +" " + day + appd()+ monthname + ", " + year + " " + hour + ":" +
minute + ":" + second +" GMT"
document.countdown.secondary.value = " Your pc thinks its "+" " + lday +" "+ lmonth + ", " + lyear + " " + lhour + ":" +
lminute + ":" + lsecond
var offdate = date-ldate
var offhour = hour-lhour
var offminute = minute-lminute
var offyear = year-lyear
var offmonth = month-(lmonth-1)
var offsecond = second-lsecond
document.countdown.offset.value = offyear +" Years"+offmonth+" Months"+offhour+" Hours"+offminute+"
Minutes"+offsecond+"Seconds"
setTimeout("clock()", 1000)
}
The html Looks like this
<form name="countdown" >
<input type="text" style="color:blue; background-color:#CCFFCC; border-width: 5px; border-color:green" value=""
name="counter" size=50>
<input type="text" style="color:blue; background-color:#CCFFCC; border-width: 5px; border-color:green" value=""
name="secondary" size=36>
<input type="text" style="color:blue; background-color:#CCFFCC; border-width: 5px; border-color:green" value=""
name="offset" size=50></form>
I am trying to work out where
getDate() gets its time from - it seems to ignore my local system time .
get UTCDate() I assume gets its time from the net .
I have set my local timezone to australia as I am in GMT at present anyway - but the following code ( hope its not me being silly ) returns 0 value
- I know this doesnt look important but Im trying to understand how things work and am about to punch monitor :(
Long code snippet sorry
function clock() {
var date = new Date()
var year = date.getUTCFullYear()
var month = date.getUTCMonth()
var day = date.getUTCDate()
var hour = date.getUTCHours()
var minute = date.getUTCMinutes()
var second = date.getUTCSeconds()
var months = new Array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC")
var monthname = months[month]
if (minute < 10) {
minute = "0" + minute
}
if (second < 10) {
second = "0" + second
}
var ldate = new Date()
var lyear = ldate.getFullYear()
var lmonth = ldate.getMonth()+1
var lday = ldate.getDate()
var lhour = ldate.getHours()
var lminute = ldate.getMinutes()
var lsecond = ldate.getSeconds()
if (lminute < 10) {
lminute = "0" + lminute
}
if (lsecond < 10) {
lsecond = "0" + lsecond
}
document.title = greeting () +" " + day + appd()+ monthname + ", " + year + " " + hour + ":" + minute + ":" + second+ "
GMT"+" Your time "+" " + lday +" "+ lmonth + ", " + lyear + " " + lhour + ":" + lminute + ":" + lsecond
window.status = greeting () +" " + day + appd()+ monthname + ", " + year + " " + hour + ":" + minute + ":" + second + "
GMT"+" Your time "+" " + lday +" "+ lmonth + ", " + lyear + " " + lhour + ":" + lminute + ":" + lsecond
document.countdown.counter.value =greeting () +" " + day + appd()+ monthname + ", " + year + " " + hour + ":" +
minute + ":" + second +" GMT"
document.countdown.secondary.value = " Your pc thinks its "+" " + lday +" "+ lmonth + ", " + lyear + " " + lhour + ":" +
lminute + ":" + lsecond
var offdate = date-ldate
var offhour = hour-lhour
var offminute = minute-lminute
var offyear = year-lyear
var offmonth = month-(lmonth-1)
var offsecond = second-lsecond
document.countdown.offset.value = offyear +" Years"+offmonth+" Months"+offhour+" Hours"+offminute+"
Minutes"+offsecond+"Seconds"
setTimeout("clock()", 1000)
}
The html Looks like this
<form name="countdown" >
<input type="text" style="color:blue; background-color:#CCFFCC; border-width: 5px; border-color:green" value=""
name="counter" size=50>
<input type="text" style="color:blue; background-color:#CCFFCC; border-width: 5px; border-color:green" value=""
name="secondary" size=36>
<input type="text" style="color:blue; background-color:#CCFFCC; border-width: 5px; border-color:green" value=""
name="offset" size=50></form>