8 Replies Latest reply on May 9, 2011 7:20 AM by Drew747

    Does (new Date()) use local system time or remote server time

    SOGC Level 1

      When users run Flex applications, does the internal Flex application time correspond to the user's local system time, or the remote server's time?

       

      We're implementing time-zone related features into our application, and need to know whether to compensate for the (new Date()) function calls, and adjust those times to match the user's timezone.

        • 1. Re: Does (new Date()) use local system time or remote server time
          tooMuchTrouble Level 3

          On 5/8/2011 3:40 PM, SOGC said:

          When users run Flex applications, does the internal Flex application time

          correspond to the user's local system time, or the remote server's time?

           

          local time of course.

           

          We're implementing time-zone related features into our application, and need

          to know whether to compensate for the (new Date()) function calls, and adjust

          those times to match the user's timezone.

           

          pass the datetimes back & forth as epoch offsets. the flex app will handle local tz.

          • 2. Re: Does (new Date()) use local system time or remote server time
            SOGC Level 1

            Thanks, Paul - we're using WebORB for .NET and are storing our times in SQL Server 2005.

             

            We typically don't even need to use dates in Flex except a few exceptions - in cases that we do, we pass the converted date from SQL Server (i.e., the date stored in SQL server that's already been converted to the correct timezone), and then compare it to a date created locally in Flex.

             

            So, I believe that we're doing that appropriately.

            • 3. Re: Does (new Date()) use local system time or remote server time
              Level 2

              Or use getdate() inside transact-sql insert stmt to use svr time

              • 4. Re: Does (new Date()) use local system time or remote server time
                SOGC Level 1

                We do use that for certain DB-related operations, and use the web server's time for general business operations.

                 

                Our main concern is that the local date() in Flex can safely be used without any conversations (as it pertains to the time zone).

                 

                The users will select their time zone in the Flex application, and that'll convert all of the DateTime.Now() created on the web server side.  The dates stored in the DB then reflect the client's time zone, and any processing done on their DB data is done based on the client's time zone.  If the local new Date() function is compared to a date pulled from the DB, then the time zones should match.

                 

                It's not a perfect solution but given our time constraint it should work.

                • 5. Re: Does (new Date()) use local system time or remote server time
                  tooMuchTrouble Level 3

                  i think you better test first, else tz hell might be waiting for you.

                   

                  as i recall there's no tz info associated w/sql server datetimes so you're liable to end up w/the web server's tz. if so, the flex app will misinterpret the datetimes as being in the web server tz & "correct" for them client side--it happens w/coldfusion backends. so usually the safest bet is to pass epoch offsets back & forth.

                   

                  but test first.

                  • 6. Re: Does (new Date()) use local system time or remote server time
                    Level 2

                    And if they accidentally choose the wrong timezone upon the next login   Or second machine correct time zone but wrong system time

                    • 7. Re: Does (new Date()) use local system time or remote server time
                      ipauland

                      It's a poor decision to store time related data in terms of the users timezone. Always save universal (GMT) times so that no matter what the local timezone is the data reflects the time correctly and will be displayed correctly whatever the local timezone. After all, if it's 2PM in one timezone, another user whose timezone is differrent, doesn't want to see what the time is in another timezone, they want to see it in their local time; nor should they need to know what timezone was used when the data was saved.

                       

                      Sometimes systems need to display times that are always relative to the location to which they pertain (for example, out of country call-centres where interaction with the customer should always be in the customers local time),and that can be done too.

                      • 8. Re: Does (new Date()) use local system time or remote server time
                        Level 2

                        Could not agree more.  user login so you can save their profile for their time zone once. Adobe should take your advice too everything is in pst.

                         

                        Date: Mon, 9 May 2011 07:48:06 -0600

                        From: forums@adobe.com

                        To: drewpierce@live.com

                        Subject: Does (new Date()) use local system time or remote server time

                         

                        It's a poor decision to store time related data in terms of the users timezone. Always save universal (GMT) times so that no matter what the local timezone is the data reflects the time correctly and will be displayed correctly whatever the local timezone. After all, if it's 2PM in one timezone, another user whose timezone is differrent, doesn't want to see what the time is in another timezone, they want to see it in their local time; nor should they need to know what timezone was used when the data was saved.

                         

                        Sometimes systems need to display times that are always relative to the location to which they pertain (for example, out of country call-centres where interaction with the customer should always be in the customers local time),and that can be done too.

                        >