1 Reply Latest reply on Jan 6, 2010 7:01 PM by chris.huston.t10

    Date as a value

    ACFlex

      Hey all -

       

      Looking to see if anyone has been able to use the date as a value for calculating timed events.

       

      Previous API application building using the AR System from Remedy for example, time started with 01/01/1900 as 1, and worked from there in seconds, so that timestamping events was a calculation based on seconds since that date.

       

      I am still trying to figure out if there is a way to use a numeric representation for 'Today' when a users launches the application, and then based on whatever that value is add 60*60*24*14 + Today to set a date range.

       

      For example:

       

                <mx:DateChooser id="dateChooserMain" yearNavigationEnabled="true" width="175" height="145"

                    disabledRanges="{[ {rangeEnd: new Date(Today + 15days)} ]}" color="0x000000"/>

       

      It seems like there should be some way for the SWF to see the system date/clock, and determine what value Today is, and then know to disable a range of available dates {<=(Today+1296000)}

       

      Maybe it's just wishful thinking, but if anyone has been able to find a way to force the application to see a representation of Today in terms of Date, then I'd love to hear how you did that.

       

      Cheers,

       

      Rich

        • 1. Re: Date as a value
          chris.huston.t10 Level 3

          You can use the getTime() method to get the number of miliseconds that have elapsed since 1970. You can then perform whatever arithmetic operations you need and convert the value back to a date if needed.

           

          var today:Date = new Date();

          var todayMS:uint = today.getTime();

          var oneDay:uint = 1000 * 60 * 60 * 24;

          var yesterday:Date = new Date(todayMS - oneDay);

           

          Chris