/* In flash, the date class manages the date and time information.
Current date. You can create a date object */
VaR now: Date = new date ();
Trace (now);/* output the current time and date in the format:
Sun Jul 27 19:45:57 GMT + 0800 2014 */
/* In the code above, the date object includes the current second, minute, hour,
Information such as the number of weeks, day, month, year, and time zone.
Return the week value and date value without returning the time or time zone. You can use date
Todatestring () method of the object .*/
VaR now1: Date = new date ();
Trace (now1.todatestring ();/* output the current time and date. The format is as follows:
Sun Jul 27, 2014 */
/* Use the hours attribute of the date class to obtain the current Hour Information
Common attributes of date objects include:
Fullyear returns the complete year value, for example, 2014
Month returns the month value. The month value ranges from 0 ~ 11, Its 0 table January
Date: returns the value of the specified day of the month, ranging from 1 ~ 31
Day returns the value of the week, ranging from 0 ~ 6, with 0 table Sunday
Minutes returns the minute value, ranging from 0 ~ 59
Milliseconds returns the number of milliseconds in the object, ranging from 0 ~ 999 */
Trace (now. hours); // a typical use of this attribute is the production of an electronic clock.
/* In addition to the attribute of the date class to obtain the current event information, you can also use
Some methods are used to obtain time information with the same effect, such as the current hour information */
Trace (now. gethours ());
/* The above method obtains the number of hours in the current time zone of the computer.
In a computer (GMT +), the gethours () method returns the hours of Beijing time. If
To obtain the world standard time, use the getutchours () method .*/
Trace (now. getutchours ());
/* Then, through Universal Time (UTC), we can easily obtain any time zone in the world
Current time. For example, New York time zone (GMT-05: 00), define it as string variable timezone,
This section describes the substring () method of a string. It intercepts 5th and 6th characters in the string and is highly efficient.
Convert to numeric type and save it in the timezonehours variable. In this case, timezonehours =-5
It means 5 hours later than the general time. We only need to get the current general hours to get
Current New York time */
VaR timezone: String = "GMT-05: 00 ";
VaR timezonehours: Number = Number (timezone. substring (4, 6 ));
VaR now_1: Date = new date ();
Trace (now_1.gethours ();/* the output result varies with the setting and test time.
If the current time is Beijing time, 19 */
Trace (now_1.getutchours ()-timezonehours); // add or subtract depending on the time zone
/* Output 6, indicating that the current New York time is six o'clock A.M.
/* When the date object is created, if we do not input any parameters, the output will be the current time. If
If you pass in parameters, you can set the object time and date. Date objects, which can be passed in with 7 parameters,
The values are year, month, day, hour, minute, second, and millisecond. Note that the month range is 0 ~ 11 indicates */
VaR Date: Date = new date (hz6, 27,19, 52 );
Trace (date); // output Sun Jul 27 19:52:00 GMT + 0800 2014
// You can also modify the time and date in the object and use the sethours () method to modify the previous Code hours.
Date. sethours (20)
Trace (date); // output Sun Jul 27 20:52:00 GMT + 0800 2014
/* The date object also provides the parse () method. You can call a date as from January 1, January 1, 1970 to date.
Milliseconds passed */
VaR datenow: String = "Sun Jul 2014 ";
Trace (date. parse (datenow); // output 1406390400000
Flash output panel preview results