Forum Moderators: open

Message Too Old, No Replies

UTC dates gone bad

scripting to get the time difference between two dates

         

natty

2:19 pm on Apr 25, 2003 (gmt 0)

10+ Year Member



sorry , i know ive posted this question before, ([webmasterworld.com ]) but it seems to have reared its ugly head once more, still no solution. im at my wits end, sadly i cant get on an IRC svr for a chat on there, and google groups take days, and we cant get newsgroups from work anyhow.
YAY.. how i love our techie dudes..

nonetheless.
the problem, for which any help will be gratefully recieved.

the function


function dayOfYear(osD,selD){
var theMonth;
todayTime = selD.getTime();
startTime = osD.getTime();
DoY = parseInt((todayTime - startTime))/86400000;
if (DoY%1!= 0){
DoY = DoY-(DoY%1);
}
theMonth = selD.getMonth()
DoY += 1;
return DoY;
}

osD is an offset date
selD is another date
both constructed via
osD = new Date(yr,mnth,day,12);

the idea of the function is to get the number of days between osD and selD.
sadly when selD is in the nov-mar bracket (winter time clocks) the DoY gets one day out.

WHY!?

dmorison

2:38 pm on Apr 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi natty,

Just did a quick Google search and found a page that might help. It's about solving the Y2K problem and has a JavaScript function to calculate the number of days between two dates.

I've sent you a sticky with the URL.

Cheers.

natty

2:57 pm on Apr 25, 2003 (gmt 0)

10+ Year Member



thank you thank you thank you.
i dont know why , and i dont really care, but it seems to work a treat.
if i woz a lady, ive offer to mother your children.
sadly im not, so youll have to make do with a thousand thankyous..

cheers matey

nat

tedster

4:15 pm on Apr 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks to dmorison for sending me the address for the successful script. For anyone one who wants to check it out, here it is:

[developer.irt.org...]

Xuefer

2:23 am on Apr 26, 2003 (gmt 0)

10+ Year Member




alert(new Date(date1.valueOf() - date2.valueOf()).getUTCFullYear) // this is time-diff, use whatever getUTC***