homepage Welcome to WebmasterWorld Guest from 50.17.176.149
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Visit PubCon.com
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
jamie




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

hi,

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!

 

gph




msg:1484932
 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.

Date.prototype.moveDays=function(days){
return new Date(this.setDate(this.getDate()+days))
};

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


jamie




msg:1484933
 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.

thanks

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved