Inside the AS3 Date class: Properties and methods
Posted on April 10, 02008
Filed Under Development, Flash, Latham
I've left properties and methods to the end because they are already well documented in the official docs. They are really just here for completeness. If you have worked with the Date object in a previous version of Actionscript then there is one point worth mentioning. You are probably used to working with methods like this:
var hours = d.getHours() // and d.setHours(5)
Although all these legacy methods are still available to you, you might want to consider moving over to the property syntax. This is new in AS3 and much cleaner to use. The property equivalents of the above methods look like this:
var hours:Number = d.hours // and d.hours = 5
These new properties make the get() methods largely redundant but the set() methods can be still be useful as most of them take multiple parameters; for example the full setHours() syntax looks like this:
setHours( hour:Number, minute:Number, second:Number, millisecond:Number ):Number
Properties and methods
At the risk of stating the obvious, any property or method marked as UTC will return or set a value in UTC; anything else is in local time.
Milliseconds: the number of Milliseconds as an integer between 0 - 999
milliseconds:Number millisecondsUTC:Number setMilliseconds( millisecond:Number ):Number setUTCMilliseconds( millisecond:Number ):Number
Seconds: the number of Seconds as an integer between 0 - 59
seconds:Number secondsUTC:Number setSeconds( second:Number, millisecond:Number ):Number setUTCSeconds( second:Number, millisecond:Number ):Number
Minutes: the number of Minutes as an integer between 0 - 59
minutes:Number minutesUTC:Number setMinutes( minute:Number, second:Number, millisecond:Number ):Number setUTCMinutes( minute:Number, second:Number, millisecond:Number ):Number
Hours: returns the number of Hours as an integer between 0 - 23
hours:Number hoursUTC:Number setHours( hour:Number, minute:Number, second:Number, millisecond:Number ):Number setUTCHours( hour:Number, minute:Number, second:Number, millisecond:Number ):Number
Day of week: returns the day of the week as an integer between 0 - 6
(0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday)
day:Number dayUTC:Number
Day of month: returns the day of the month as an integer between 1 - 31
date:Number dateUTC:Number setDate( day:Number ):Number setUTCDate( day:Number ):Number
Month: returns the number of Months as an integer between 0 - 11
(0 = January, 1 = February, 2 = March, 11 = December)
month:Number monthUTC:Number setMonth( month:Number, day:Number ):Number setUTCMonth( month:Number, day:Number ):Number
Year: returns the Year in the Gregorian calendar as a 4 digit integer
fullYear:Number fullYearUTC:Number setFullYear( year:Number, month:Number, day:Number ):Number setUTCFullYear( year:Number, month:Number, day:Number ):Number
Strings:
toDateString():String toLocaleDateString():String toString():String toLocaleString():String toUTCString():String toTimeString():String toLocaleTimeString():String
Related Journal Entries
- A review of Temporal Web Standards
- Inside the AS3 Date class: Introduction
- Inside the AS3 Date class: The Basics
- Inside the AS3 Date class: The constructor
- Inside the AS3 Date class: Timezones and Daylight Saving Time
- The project architecture
- Hacking the Date class for GeoLocation
- Projects update March 2009
- Big History
- Project updates April 2009
- AS3 component: AnimatedButton
- Measuring Time: Datatypes
- Revelation
- Creating a main preloader in Flash CS3
- Minkowski Spacetime
Comments
Leave a Comment
If you would like to make a comment, please fill out the form below.

