One of the Flex date actions (get current date-use timer)

Source: Internet
Author: User

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.}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.