5 Replies Latest reply on Oct 7, 2008 4:42 PM by Mitek17

    Date Problem

    larcelarcen
      Using RemoteObject, I get a date from a SQL Server 2005 database and pass it through a CFC to Flex.

      Using a test file I can generate the output of the CFC and the date shows as 2007-10-27 15:50:00.0 which is the correct date/time in the database.

      If I run the swf and immediately call toString() on this returned date in Flex, it shows Sun Oct 11:50:00 GMT-0400 2007


      In other words something has added 4 hours to the date.

      Does anyone know what is going on here?
        • 1. Re: Date Problem
          BridalLive
          I am having the same problem. The devguide says that the dates are converted to UTC. I can't understand why eastern times is GMT -0400 though.

          did you figure this out?
          • 2. Re: Date Problem
            to get the date in the required formate you will have to modify the date object you are getting from remoteObject.
            Try this,
            var newDate:String = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + " " + date.getHours()+":"+date.getMinutes() + ":"+date.getSeconds ;
            You can change the date formate any way you want.
            • 3. Re: Date Problem
              Agarwal_ankur
              i am also getting wrong month.
              i am getting 9(September) in stead of 10(October).
              I have used
              var newDate:String = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + " " + date.getHours()+":"+date.getMinutes() + ":"+date.getSeconds ;

              But i m getting wrong month.
              • 4. Re: Date Problem
                Mitek17 Level 1
                quote:

                Originally posted by: Agarwal_ankur
                i am also getting wrong month.
                i am getting 9(September) in stead of 10(October).
                I have used
                var newDate:String = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + " " + date.getHours()+":"+date.getMinutes() + ":"+date.getSeconds ;

                But i m getting wrong month.


                Month starts from 0. You should align it with +1.

                Cheers,
                Dmitri.
                • 5. Re: Date Problem
                  Mitek17 Level 1
                  quote:

                  Originally posted by: larcelarcen
                  Using RemoteObject, I get a date from a SQL Server 2005 database and pass it through a CFC to Flex.

                  Using a test file I can generate the output of the CFC and the date shows as 2007-10-27 15:50:00.0 which is the correct date/time in the database.

                  If I run the swf and immediately call toString() on this returned date in Flex, it shows Sun Oct 11:50:00 GMT-0400 2007


                  In other words something has added 4 hours to the date.

                  Does anyone know what is going on here?



                  What is the data type in your DB for dates? Does it have a timezone?
                  What if you try to use today's date and check the result?

                  PS There is also Flex bug - it does not correctly handles daylight savings on certain operations with Date, but 4 hours difference seems to be too much.
                  https://bugs.adobe.com/jira/browse/SDK-14983

                  Cheers,
                  Dmitri.