Skip navigation
Currently Being Moderated

Local time

Jul 26, 2012 9:05 AM

Let's say I have a function with a signature like this: private function (date:Date) {     trace(date.datetime); } ... when I send a date value into this function does the time portion gets converted into local time automatically?  Thanks

 
Replies
  • Currently Being Moderated
    Jul 26, 2012 10:50 PM   in reply to Zolotoj

    Trace calls toString() on the expression.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 12:58 PM   in reply to Zolotoj

    I think you are describing a classic date management problem that has no single good solution.  The problem is that if you store dates in local time and don’t store timezone information, you don’t have enough data to view the date as desired on other clients especially if they are in other time zones.  You will find other past discussions on this topic.

     

    The basic problem is that, if you have, say, a west coast office and an east coast office and the west coast office records a transaction at 9am and stores it as 9am, the east coast office doesn’t know whether it happened at 9am their time or 12pm their time.  There is another version of the problem where things are stored in GMT but you really want to reproduce the local time display at the office that made the transaction.

     

    One solution offered is to not use date/time and simply use a string.  Otherwise, you have to know which office made the transaction and what time zone it is in.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 1:08 PM   in reply to Zolotoj

    I don’t know AMF that well.  I wouldn’t be surprised if Date serializes to its UTC value as that would be a good default.

     

    I believe that means you can’t use Date if you want to store something else.  You would need a custom class or use String.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 1:19 PM   in reply to Zolotoj

    You could just store the time by converting Date to a String.

     

    A custom class would store hour/minutes/seconds/timezone, etc.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 1:44 PM   in reply to Zolotoj

    I’m probably the one missing something, but if Date is holding 9am PDT, AMF probably converts that to GMT, but if you convert it to the string “9am PDT” and store that, then I think you have everything you need.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 2:48 PM   in reply to Zolotoj

    Oh yeah, that’s another variant of the problem.  You want to display a time based on a certain time zone regardless of the time zone of the user.  I think folks store UTC and then convert to the desired timezone in the view controls.  You can also convert to the desired timezone before converting to string.  Fundamentally you have to know the user’s time zone and the “standard” timezone.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 28, 2012 9:47 PM   in reply to Zolotoj

    Then you convert to a string at the user’s computer and display that string everywhere.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 29, 2012 9:40 PM   in reply to Zolotoj

    That’s why I am suggesting using String instead of Date.  You know what string you want to see regardless of timezone, so just store that string.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points