Click to See Complete Forum and Search --> : Time and date question


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>

Jonathan
11-21-2003, 08:50 PM
ok....

first off, every time you do a variable, or a string you need to end it like this:


var hello = "Hello World!!!"; //Notice the ";"

var hello = "Hello" + your variable + "WORLD!!!"; //Again, the ";"


That needs to be added a lot if I am not mistaken. Let me know if this works... Then post the code.

Ninjagranny
11-22-2003, 04:09 AM
I had thought that the ; were optional but I will put them in .

The functions are returning values its just they both return the current system time

Here is a link to the script to show you what i mean

http://ninjagranny.servebeer.com/test/titlebarclock.html

Thank you

Ninjagranny
11-22-2003, 11:07 AM
I have posted a url to show you what I mean .

Thank you

Jonathan
11-22-2003, 11:11 AM
cool...

Ninjagranny
11-22-2003, 11:33 AM
does it work for you then ?

i just get 2 identical dates and zeroes in the offset

Jonathan
11-22-2003, 11:34 AM
It works for me...

Ninjagranny
11-22-2003, 11:38 AM
lol

wonder why it doesn't for me -- even when i reset my pc clock ..

Ah well - and thx matey :)

Jonathan
11-22-2003, 11:38 AM
sure... (if i did anything :))

Ninjagranny
11-22-2003, 11:43 AM
I was getting so %!%$ off with it not working and me not being able to fix it that i needed an outlet -- :) so my monitor -- my wall and the nearby objects all owe you their life :)

LOL

I love this board ... people are so nice .. my next project is a full dungean bash with multi levels and multi fight styles with different weapons .... so ill be back here often <cackle> bbut you may be lucky i may give it up and right it in java

Jonathan
11-22-2003, 11:48 AM
:)