15 Replies Latest reply on Jul 29, 2012 9:40 PM by Flex harUI

    Local time


      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

        • 1. Re: Local time
          Flex harUI Adobe Employee

          Trace calls toString() on the expression.

          • 2. Re: Local time
            Zolotoj Level 3

            I see. I guess, my question then is how to preserve a datetime value from SQL server and show it  as it was initially stored in the database?

            • 3. Re: Local time
              Flex harUI Adobe Employee

              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.

              • 4. Re: Local time
                Zolotoj Level 3

                A bit simpler then that. I want show a time as it was originally entered and stored to the database. What I see is this is an AMF problem (we use WebORB) that applies UTC before data hits Flex. Am I correct?

                • 5. Re: Local time
                  Flex harUI Adobe Employee

                  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.

                  • 6. Re: Local time
                    Zolotoj Level 3

                    use String do you mean getting a string representation of dates from the server? A custom class of what?  Thanks

                    • 7. Re: Local time
                      Flex harUI Adobe Employee

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


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

                      • 8. Re: Local time
                        Zolotoj Level 3

                        Unless I am missing something here  ....  Converting Date to a String does not help because Date is already converted into a local time at a time of assigning a value.

                        • 9. Re: Local time
                          Flex harUI Adobe Employee

                          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.

                          • 10. Re: Local time
                            Zolotoj Level 3

                            Here is what I am getting: Fri Jul 20 03:00:00 GMT-0500 2012 when I use Central Time  Fri Jul 20 04:00:00 GMT-0400 2012 when I use Eastern Time.  But I dont want that. I want to have it as the first sample in any time zone.

                            • 11. Re: Local time
                              Flex harUI Adobe Employee

                              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.

                              • 12. Re: Local time
                                Zolotoj Level 3

                                No, I do not want to convert anything. I f a user enters a time of an appointment as 2 pm I want to see  2 pm everywhere regardless the time zone.

                                • 13. Re: Local time
                                  Flex harUI Adobe Employee

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

                                  • 14. Re: Local time
                                    Zolotoj Level 3

                                    I think I know what the problem is. We are using WebORB (AMF serialization) and by the time a value hits Flex the time zone has already been applied and nothing can help me to show a time in its original value.

                                    • 15. Re: Local time
                                      Flex harUI Adobe Employee

                                      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.