0 Replies Latest reply on Oct 9, 2008 5:53 AM by vuckovid

    Dates (Converting from UTC to Eastern)

      I was wondering if anyone had any prior experience or examples/thoughts on how one would convert a local machines datetime into a date representing the Eastern time zone. My initial thoughts is to convert the machines local date to UTC, and then find a way to convert the UTC time to eastern. The following is a code snippet performing the first part of the logic (local time to UTC).

      public static function convertLocalToUTC(localDate:Date):Date {
      var offsetMilliseconds:Number = localDate.getTimezoneOffset() * 60 * 1000;
      localDate.setTime(localDate.getTime() + offsetMilliseconds);
      return localDate;

      After i have the UTC time, however, i'm stuck on how to convert it to Eastern Time. The main reason i'm stuck is because i can't determine if it should take day light savings into effect or not (also to note, not all areas where the application will be run have day light savings, so you can't assume that).

      Is there a way to create a Date object in a different local time zone than the machine is?

      For instance: var date:DAte = new Date() would create a date in the machines local time zone, is there a way to change this default functionality and create one that is in a different time zone?

      I'd hate to have to run logic to determine what is the 2nd sunday or whatever in one month, and manually find out if the country is observing day ligth savings at that time thru date manipulation, but that seems to be the only 100% solution.

      Any thoughts on this would be appreciated.