122
Chapter 6: Working with dates and times
Timing might not be everything, but it's usually a key factor in software applications. ActionScript™ 3.0 provides
powerful ways to manage calendar dates, times, and time intervals. Two main classes provide most of this timing
functionality: the Date class and the new Timer class in the flash.utils package.
Contents
Basics of dates and times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Managing calendar dates and times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Controlling time intervals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Example: Simple analog clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Basics of dates and times
Introduction to working with dates and times
Dates and times are a common type of information used in ActionScript programs. For instance, you might need to
know the current day of the week or to measure how much time a user spends on a particular screen, among many
other possibilities. In ActionScript, you can use the Date class to represent a single moment in time, including date
and time information. Within a Date instance are values for the individual date and time units, including year,
month, date, day of the week, hour, minutes, seconds, milliseconds, and time zone. For more advanced uses, Action-
Script also includes the Timer class, which you can use to perform actions after a certain delay or at repeated
intervals.
Common date and time tasks
This chapter describes the following common tasks for working with date and time information:
Working with Date objects
Getting the current date and time
Accessing individual date and time units (days, years, hours, minutes, and so on)
Performing arithmetic with dates and times
Converting between time zones
Performing repeating actions
Performing actions after a set time interval
Important concepts and terms
The following reference list contains important terms that you will encounter in this chapter:
UTC time: Coordinated Universal Time—the “zero hour” reference time zone. All other time zones are defined
as a number of hours relative to (ahead of or behind) UTC time.

Get ADOBE® FLEX® 3: PROGRAMMING ACTIONSCRIPT™ 3.0 now with O’Reilly online learning.

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