2 Replies Latest reply on Jun 24, 2009 7:05 PM by Chunick

    datetime manipulation

    bobo_freak

      Hello,

       

      Anyone knows an easy way to do time and date manipulation?

       

      I need to be able to add 1:15:32 to 2009, 6, 25 23:56:04 = 2009, 6, 26 1:11:36

       

      Thanks

       

       

        • 1. Re: datetime manipulation
          Sean_Wilson Adobe Community Professional

          I suspect that if you spent enough time with the JavaScript Date() object you'd find a way to do this. Something like:

          // - convert 2009, 6, 25 23:56:04 to its milliseconds representation by
          //   using a Date() object and its various set...() methods
          // - use lingo/JS to convert 1:15:32 to milliseconds
          // - add the two ms values together
          // - convert to a date using JS and grab YYYY, M, D H:M:S
          
          • 2. Re: datetime manipulation
            Chunick Level 3

            Director's built-in date object can do it, along with the HMStoFrames() and framesToHMS() methods:

             

            d = date(2009, 6, 25)

            secs = HMStoFrames("23:56:04", 1, FALSE, FALSE) + HMStoFrames("1:15:32", 1, FALSE, FALSE)

            if secs > 86400 then

            days = secs / 86400

            secs = secs mod 86400

            end if

            d = d + days

            d.seconds = secs

             

            put d

            -- date( 2009, 6, 26 )

            put d.seconds

            -- 4296

            put framesToHMS(d.seconds, 1, FALSE, FALSE)

            -- " 01:11:36.00 "