Works fine here using "2008/11/02" as the starting date, but that's probably 
because winter time kicks in on a different date here 
(which I don't know).
Summer time kicks in on "2008/03/30" so I tried that instead.

Notice that the new date has 1 hour added.
I guess when using the winter time it would subtract 1 hour, resulting in the 
same date as the original.

// tested
var ms:Number = 24*60*60*1000;
var d:String = "2008/03/30";
var newDate:Date = new Date(Date.parse(d)+ms);
trace(new Date(Date.parse(d)));
trace(newDate);

//output
Sun Mar 30 00:00:00 GMT+0100 2008
Mon Mar 31 01:00:00 GMT+0200 2008

Gotta luv date manipulations.. fun fun..

----- Original Message ----- 
From: "Doug Lowder" <[EMAIL PROTECTED]>
To: <flexcoders@yahoogroups.com>
Sent: Friday, February 08, 2008 1:56 AM
Subject: [flexcoders] Re: What is the best way to add a day to a date?


It's not that simple, because of Daylight Savings Time.  Try the
following on a machine with the timezone set to something that
follows DST:

var ms:Number = 24*60*60*1000;
var d:String = "2008/11/02";
var newDate:Date = new Date(Date.parse(d)+ms);

You'll get the same day, 2008/11/02, because Nov 2 2008 will be a 25-
hour day in some locations due to the clocks being set back.  You'd
need to convert to UTC before doing the math, or check the timezone
of the dates with getTimezoneOffset() and adjust accordingly if
needed.





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to