Name
Date( ) Global Function — a string representing the current date and time
Availability
Flash 5
Synopsis
Date( )
Returns
A string containing the current date and time.
Description
The Date( )
function returns a human-readable
string that expresses the current date and time relative to the local
time zone. The string also includes the GMT offset (the number of hours difference
between local time and Greenwich Mean Time).
Be sure not to confuse the global Date( )
function with the Date( )
class constructor. The
Date( )
function returns the date formatted as a
standard, if terse, string. It is convenient for humans but not very
useful inside a program where you need to manipulate dates and times.
For that purpose, you are better off using objects of the
Date
class, which allow convenient independent
access to the year, month, day, and time.
Example
To place the current time and date in a text field with minimal fuss,
we can use the Date( )
function as follows:
myTextField = Date( ); // Sets myTextField to a string formatted as follows: // "Mon Aug 28 16:23:09 GMT-0400 2000"
See Also
The Date
class, Date.UTC( )
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.