1. Get System Current Date
1. var variable name: Date=new Date ();
2. Var today:date=new Date ();
3. Trace (today);
Because Flex is a client program, the time to get is also the client time, to get the service end date needs to be matched with other server language acquisition, such as Php,java,asp.net.
2. Get a specific value from a date
Property |
Description |
Fullyear |
Represents a 4-digit year, such as 2010 |
Date |
Represents the day of the month, range 1~31 |
Month |
Represents a month, expressed as a number, ranging from 0~11 |
Day |
The day of the week, range from 0~6 |
Hours |
Hour, 0~23 |
Minutes |
Minutes, 0~59 |
Seconds |
Represents seconds, 0~59 |
Milliseconds |
Represents milliseconds, 0~999 |
Format time:
1. Importmx.controls.Alert;
2. Import Mx.formatters.DateFormatter;
3.
4. Private function HelloWorld (evt:event): void{
5. var dateformatter:dateformatter = new Dateformatter ();
6. dateformatter.formatstring = "Yyyy-mm-dd JJ:NN:SS";
7. Var now:string= dateformatter.format (New Date ());
8. mytext.text= "The current time is:" + now;
9. Mx.controls.Alert.show (Mytext.text, "Current Time");
10.}
3. Using Timers
Format: var variable name: Timer=new Timer (time interval);
To add a listener format for a timer: Timer object. Addevebtlistener (Timer.timer, handler function name);
1. Functionclickbutton (): void
2. {
3. var timer:timer =new timer (1000);
4. Timer.addeventlistener (Timerevent.timer,ontimer);
5. Timer.start ();
6.}
7. Functionontimer (event:timerevent): void
8. {
9. Alert.show ("1111");
10.}