homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

dealing with summer time
romance standard time +2

 8:08 am on Mar 18, 2006 (gmt 0)


i've got a function which checks that there are minimum 3 days between 2 dates.

currently i convert to milliseconds and subtract one from the other and check that it is < 24*3600*1000*3

but this is giving me problems if i check dates around the 27th march - which is when summer time starts - i lose an hour and the function returns negative even there are 3 days in between.

is there a way around this particular problem?

many thanks!



 5:12 pm on Mar 18, 2006 (gmt 0)

Yes, you should avoid calculating days using milliseconds because of daylight savings time. This should give you the idea.

return new Date(this.setDate(this.getDate()+days))

alert('-20 = '+new Date().moveDays(-20)+'\n\n+20 = '+new Date().moveDays(20))


 9:00 am on Mar 20, 2006 (gmt 0)

hi gph,

that's what i've now done. i didn't actually understand what you meant, until i did some investigating and now it's clear.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved