Chapter 10. Dates and Times


Dates and times are important to many ActionScript applications, particularly when you develop more robust applications that offer users services. Date and time values are important for determining the amount of time that has elapsed for timed operations, for determining whether a user’s trial membership is active, and for storing transaction dates, to name but a few scenarios.

ActionScript stores dates and times internally as Epoch milliseconds, which are the number of milliseconds that have elapsed since the Epoch, namely midnight, January 1, 1970 Coordinated Universal Time (UTC). For our purposes, UTC is essentially equivalent to the more familiar Greenwich Mean Time (GMT). (See to learn about the subtle distinctions.) Many programming languages store dates in terms of the Epoch (often in seconds instead of milliseconds); therefore, you can readily work with date and time values that have been imported from other sources (and vice versa).

In addition, the Date class allows you to set and get date and time values in terms of years, months, days, and so on, using methods such as getFullYear( ), setFullYear( ), getMonth( ), and setMonth( ). These methods are for your convenience, but the values are stored internally as Epoch milliseconds.

Get Actionscript Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.