
Date Class
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
502
|
ActionScript Language Reference
Example
To place the current time and date in a text field with minimal fuss, we can use the Date()
function as follows:
someMovieClip.createTextField("output_txt", 1, 0, 0, 200, 20);
output_txt.text = Date();
// Sets the displayed text to a string formatted as follows:
// "Mon Aug 28 16:23:09 GMT-0400 2000"
Reader Exercise: Modify the preceding example using String.substring() to show the date
and time (including the hours and minutes), but eliminate the seconds and GMT offset
from the display. See the Example in the Date class entry for a much more flexible
approach.
See Also
The Date class, Date.UTC()
Date Class
current time and structured support for date information
Flash 5
Constructor
new Date()
new Date(milliseconds)
new Date(year, month, day, hours, minutes, seconds, ms)
Arguments
milliseconds The number of milliseconds between the new date and midnight of January
1, 1970 UTC (Coordinated Universal Time, akin to GMT—positive if after;
negative if before. Any required local time zone adjustment is made after the
date in UTC time is determined. For example, specifying a
milliseconds
argument of 1000 in Eastern Standard Time creates a date 1 second past
midnight on January 1, 1970 in UTC time, which translates to 7:00:01 P.M.
on December 31, 1969 ...