Date (object)
The date object allows you to obtain the time and date relative to the International Standard Time (Greenwich Mean Time, now known as UTC-Universal Coordinated Time) or the operating system running on the Flash Player. To use the date object method, you must first create a date object entity (instance ).
The date object must use a player of Flash 5 or a later version.
The date object method is not static, but can be applied to specified individual objects during use.
Date object Method Introduction:
· Getdate | get the current date based on the local time (number of the current month)
· Getday | obtains the day of the week (0-Sunday, 1-Monday...) based on the local time ...)
· Getfullyear | obtains the current year based on the local time (four digits)
· Gethours | obtains the current hour (in the 24-hour format, ranging from 0 to 23) based on the local time)
· Getmilliseconds | obtains the current number of milliseconds based on the local time
· Getminutes | obtains the current number of minutes based on the local time
· Getmonth | obtains the current month based on the local time (Note: Starting from 0: 0-Jan, 1-feb ...)
· Getseconds | obtains the current number of seconds based on the local time
· Gettime | obtains the number of milliseconds since, January 1, in UTC format.
· Gettimezoneoffset | obtains the offset value of the current time and UTC format (in minutes)
· Getutcdate | get the current date in UTC format (number of the current month)
· Getutcday | obtains the day of the week in UTC format (0-Sunday, 1-Monday ...)
· Getutcfullyear | obtains the current year (four digits) in UTC format)
· Getutchours | get the current hour in UTC format (24-hour, 0-23)
· Getutcmilliseconds | obtains the current millisecond count in UTC format.
· Getutcminutes | get the current number of minutes in UTC format
· Getutcmonth | get the current month in UTC format (Note: Starting from 0: 0-Jan, 1-feb ...)
· Getutcseconds | obtains the current number of seconds in UTC format.
· Getyear | obtains the current abbreviated year (current year minus 1900) based on the local time)
· Setdate | set the current date (number of the current month)
· Setfullyear | set the current year (four digits)
· Sethours | set the current hour (24-hour, 0-23)
· Setmilliseconds | set the current number of milliseconds
· Setminutes | set the current number of minutes
· Setmonth | set the current month (Note: 0-Jan, 1-feb ...)
· Setseconds | set the current number of seconds
· Settime | set the number of milliseconds since in UTC format
· Setutcdate | set the current date in UTC format (number of the current month)
· Setutcfullyear | current year in UTC format (four digits)
· Setutchours | set the current hour in UTC format (24-hour, 0-23)
· Setutcmilliseconds | set the current number of milliseconds in UTC format
· Setutcminutes | set the current number of minutes in UTC format
· Setutcmonth | set the current month in UTC format (Note: Starting from 0: 0-Jan, 1-feb ...)
· Setutcseconds | set the current number of seconds in UTC format
· Setyear | set the current abbreviation year (current year minus 1900)
· Tostring | converts a datetime value to a string value in the form of "date/time ".
· Date. UTC | returns the fixed time value of the specified UTC format date and time.
Create a new date object
Syntax:
New Date ();
New date (year [, month [, date [, hour [, minute [, second [, millisecond]);
Parameters:
Year is an integer between 0 and 99, corresponding to 1900 to 1999, or a specified year for four digits;
Month is an integer between 0 (January) and 11 (December). This parameter is optional;
Date is an integer between 1 and 31. this parameter is optional;
Hour is an integer between 0 (AM) and 23 (pm). This parameter is optional;
Minute is an integer between 0 and 59. this parameter is optional;
Second is an integer between 0 and 59. this parameter is optional;
Millisecond is an integer ranging from 0 to 999. this parameter is optional;
Note:
Object. Create a date object.
Player support:
Flash 5 or later versions.
Example:
The following is an example of obtaining the current date and time:
Now = new date ();
The following example creates a date object for the National Day:
National_day = new date (49, 10, 1 );
The following example shows how to use the getmonth, getdate, and getfullyear methods of the date object to obtain the time after creating a date object, and then output it in the dynamic text box.
Mydate = new date ();
Datetextfield = (mydate. getmonth () + "/" + mydate. getdate () + "/" + mydate. getfullyear ());
Date> date. getdate
Date. getdate
Syntax: mydate. getdate ();
Parameter: None
Note:
Method. Obtain the current date (number of the current month) based on the local time. The returned value is an integer between 1 and 31.
Player support: Flash 5 or later.
Date> date. getday
Date. getday
Syntax: mydate. getday ();
Parameter: None
Note:
Method. Obtain the day of the week (0-Sunday, 1-Monday...) based on the local time ...). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. getfullyear
Date. getfullyear
Syntax: mydate. getfullyear ();
Parameter: None
Note:
Method. Obtain the current year based on the local time (four digits, such as 2000 ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Example:
In the following example, a date object is created, and the year obtained using the getfullyear method is output in the output window:
Mydate = new date ();
Trace (mydate. getfullyear ());
Date> date. gethours
Date. gethours
Syntax: mydate. gethours ();
Parameter: None
Note:
Method. Obtain the current hour based on the local time (in 24-hour format, the returned value is an integer between 0 and 23 ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. getmilliseconds
Date. getmilliseconds
Syntax: mydate. getmilliseconds ();
Parameter: None
Note:
Method. Obtain the current number of milliseconds based on the local time (the returned value is an integer between 0 and 999 ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. getminutes
Date. getminutes
Syntax: mydate. getminutes ();
Parameter: None
Note:
Method. Obtain the current number of minutes based on the local time (the returned value is an integer between 0 and 59 ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. getmonth
Date. getmonth
Syntax: mydate. getmonth ();
Parameter: None
Note:
Method. Obtain the current month based on the local time (Note: from 0 to January, 1 to February ...). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. getseconds
Date. getseconds
Syntax: mydate. getseconds ();
Parameter: None
Note:
Method. Obtain the current number of seconds based on the local time (the returned value is an integer between 0 and 59 ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. gettime
Date. gettime
Syntax: mydate. gettime ();
Parameter: None
Note:
Method. Returns the number of milliseconds that have elapsed since AM, January 1, January 1, 1970, in UTC format. This method can be used to describe the same instantaneous time in different time zones.
Player support: Flash 5 or later.
Date> date. gettimezoneoffset
Date. gettimezoneoffset
Syntax: mydate. gettimezoneoffset ();
Parameter: None
Note:
Method. Obtains the offset value of the current time and UTC format (in minutes ).
Player support: Flash 5 or later.
Example:
The following example returns the offset between Beijing time and UTC time.
New Date (). gettimezoneoffset ();
The result is as follows:
480 (8 hours * 60 minutes/hour = 480 minutes)
Date> date. getutcdate
Date. getutcdate
Syntax: mydate. getutcdate ();
Parameter: None
Note:
Method. Obtain the current date in UTC format (number of the current month ).
Player support: Flash 5 or later.
Date> date. getutcday
Date. getutcday
Syntax: mydate. getutcdate ();
Parameter: None
Note:
Method. Obtain the day of the week in UTC format (0-Sunday, 1-Monday ...).
Player support: Flash 5 or later.
Date> date. getutcfullyear
Date. getutcfullyear
Syntax: mydate. getutcfullyear ();
Parameter: None
Note:
Method. Obtains the current year (four digits) in UTC format ).
Player support: Flash 5 or later.
Date> date. getutchours
Date. getutchours
Syntax: mydate. getutchours ();
Parameter: None
Note:
Method. Obtain the current hour in UTC format (in 24-hour format, the return value is an integer between 0 and 23 ).
Player support: Flash 5 or later.
Date> date. getutcmilliseconds
Date. getutcmilliseconds
Syntax: mydate. getutcmilliseconds ();
Parameter: None
Note:
Method. Obtain the current number of milliseconds in UTC format (the returned value is an integer between 0 and 999 ).
Player support: Flash 5 or later.
Date> date. getutcminutes
Date. getutcminutes
Syntax: mydate. getutcminutes ();
Parameter: None
Note:
Method. Obtain the current number of minutes in UTC format (the returned value is an integer between 0 and 59 ).
Player support: Flash 5 or later.
Date> date. getutcmonth
Date. getutcmonth
Syntax: mydate. getutcmonth ();
Parameter: None
Note:
Method. Obtain the current month in UTC format (Note: from 0 to January, 1 to February ...).
Player support: Flash 5 or later.
Date> date. getutcseconds
Date. getutcseconds
Syntax: mydate. getutcseconds ();
Parameter: None
Note:
Method. Returns the current number of seconds in UTC format. The returned value is an integer between 0 and 59 ).
Player support: Flash 5 or later.
Date> date. getyear
Date. getyear
Syntax: mydate. getyear ();
Parameter: None
Note:
Method. Obtain the current abbreviated year (current year minus 1900) based on the local time ). The local time is determined by the operating system of the Flash Player. For example, 100 is used for representation.
Player support: Flash 5 or later.
Date> date. setdate
Date. setdate
Syntax: mydate. setdate (date );
Parameter: date is an integer between 1 and 31.
Note:
Method. Set the current date (number of the current month) based on the local time ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. setfullyear
Date. setfullyear
Syntax: mydate. setfullyear (year [, month [, date]);
Parameters:
The four-digit integer specified by year indicates the specified year. The two digits do not represent the year. For example, 99 does not represent 1999, and only indicates year 99.
Month is an integer between 0 (January) and 11 (December). This parameter is optional.
Date is an integer from 1 to 31. this parameter is optional.
Note:
Method. Set the year based on the local time. If the month and date parameters are set, both the month and the date are set. The local time is determined by the operating system of the Flash Player. The value obtained by the getutcday and getday Methods changes accordingly.
Player support: Flash 5 or later.
Date> date. sethours
Date. sethours
Syntax: mydate. sethours (hour );
Parameter: hour is an integer from 0 (AM) to 23 (PM.
Note:
Method. Set the current hour based on the local time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. setmilliseconds
Date. setmilliseconds
Syntax: mydate. setmilliseconds (millisecond );
Parameter: millisecond is an integer from 0 to 999.
Note:
Method. Set the current number of milliseconds according to the local time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. setminutes
Date. setminutes
Syntax: mydate. setminutes (minute );
Parameter: minute is an integer from 0 to 59.
Note:
Method. Set the current number of minutes according to the local time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. setmonth
Date. setmonth
Syntax: mydate. setmonth (month [, date]);
Parameters:
Month is an integer between 0 (January) and 11 (December ).
Date is an integer from 1 to 31. this parameter is optional.
Note:
Method. Set the current month number based on the local time. If the date parameter is selected, the date is set at the same time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. setseconds
Date. setseconds
Syntax: mydate. setseconds (second );
Parameter: second is an integer from 0 to 59.
Note:
Method. Set the current number of seconds according to the local time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. settime
Date. settime
Syntax: mydate. settime (millisecond );
Parameter: millisecond is an integer from 0 to 999.
Note:
Method. Set the specified date in milliseconds.
Player support: Flash 5 or later.
Date> date. setutcdate
Date. setutcdate
Syntax: mydate. setutcdate (date );
Parameter: date is an integer from 1 to 31.
Note:
Method. The date is set in UTC format. Using this method will not affect the values of other fields of the date object, but the getutcday and getday methods will return the corresponding new values after the date is changed.
Player support: Flash 5 or later.
Date> date. setutcfullyear
Date. setutcfullyear
Syntax: mydate. setutcfullyear (year [, month [, date]);
Parameters:
Year represents the four-digit integer of the year, for example, 2000
Month is an integer ranging from 0 (January) to 11 (December). An optional parameter.
Date is an integer from 1 to 31. An optional parameter.
Note:
Method. The year is set in UTC format. If an optional parameter is used, the month and date are also set. The getutcday and getday Methods return a new value.
Player support: Flash 5 or later.
Date> date. setutchours
Date. setutchours
Syntax: mydate. setutchours (hour [, minute [, second [, millisecond]);
Parameters:
Hour is an integer from 0 (AM) to 23 (PM.
Minute is an integer from 0 to 59. An optional parameter.
Second is an integer from 0 to 59. An optional parameter.
Millisecond is an integer from 0 to 999. An optional parameter.
Note:
Method. Set the hours in UTC format. If an optional parameter is used, the values of minutes, seconds, and milliseconds are also set.
Player support: Flash 5 or later.
Date> date. setutcmilliseconds
Date. setutcmilliseconds
Syntax: mydate. setutcmilliseconds (millisecond );
Parameter: millisecond is an integer from 0 to 999.
Note:
Method. Sets the number of milliseconds in UTC format.
Player support: Flash 5 or later.
Date> date. setutcminutes
Date. setutcminutes
Syntax: mydate. setutcminutes (minute [, second [, millisecond]);
Parameters:
Minute is an integer from 0 to 59. An optional parameter.
Second is an integer from 0 to 59. An optional parameter.
Millisecond is an integer from 0 to 999. An optional parameter.
Note:
Method. Set the number of minutes in UTC format. If an optional parameter is used, the second and millisecond values are also set.
Player support: Flash 5 or later.
Date> date. setutcmonth
Date. setutcmonth
Syntax: mydate. setutcmonth (month [, date]);
Parameters:
Month is an integer between 0 (January) and 11 (December ).
Date is an integer from 1 to 31. this parameter is optional.
Note:
Method. Set the month in UTC format and optional date. The getutcday and getday Methods return the corresponding new values.
Player support: Flash 5 or later.
Date> date. setutcseconds
Date. setutcseconds
Syntax: mydate. setutcseconds (second [, millisecond]);
Parameters:
Second is an integer from 0 to 59. An optional parameter.
Millisecond is an integer from 0 to 999. An optional parameter.
Note:
Method. Sets the number of seconds in UTC format. If an optional parameter is used, the millisecond value is also set.
Player support: Flash 5 or later.
Date> date. setyear
Date. setyear
Syntax: mydate. setyear (year );
Parameter: year is a four-digit integer representing the year, for example, 2000.
Note:
Method. Set the year based on the local time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Date> date. tostring
Date. tostring
Syntax: mydate. tostring ();
Parameter: None
Note:
Method. Converts a datetime value to a string value in the form of "date/time ".
Player support: Flash 5 or later.
Example:
The following example outputs the national_day object of the National Day as a readable string:
VaR national_day = newdate (49, 9, 1, 10, 00 );
Trace (national_day.tostring ());
Output (for Pacific Standard Time ):
Result: Sat Oct 1 10:00:00 GMT + 0800 1949
Date> date. UTC
Date. UTC
Syntax: Date. UTC (year, month [, date [, hour [, minute [, second [, millisecond]);
Parameters:
Year represents the four-digit integer of the year, for example, 2000
Month is an integer between 0 (January) and 11 (December.
Date is an integer from 1 to 31. An optional parameter.
Hour is an integer from 0 (AM) to 23 (PM.
Minute is an integer from 0 to 59. An optional parameter.
Second is an integer from 0 to 59. An optional parameter.
Millisecond is an integer from 0 to 999. An optional parameter.
Note:
Method. Returns the number of milliseconds from AM, January 1, January 1, 1970. This is a static method that does not require specific objects. It can create a new date object in UTC format, while new date () creates a date object in local time.
Player support: Flash 5 or later.