Here is an example
showing how a Date object might be instantiated:
var birthDate : Date = new Date( 1976, 10, 3, 13, 15, 0 );
This example instantiates the variable birthDate with a date and time: the 3rd of November 1976 at
13:15 in the afternoon. As you can see, the value supplied for month has been set to 10, rather than 11 for
November. This is not an error. Unfortunately, because of ECMA specification, the month value starts
at 0, rather than 1, so this value alone must be set one less than the expected value.
Luckily, you won ??™ t have to provide this kind of instantiation every time you require a date object. For
example, if it ??™ s the current date and time you ??™ re after, the Date class provides a now method that
initializes the date for you with the current date and time:
var birthDate : Date = Date.now();
Part I: The Core Language
52
You can also create a Date object from a string or float using fromString or fromTime , respectively. The
string instantiation requires that a certain format be met containing either the date, time or date and time
using the format YYYY - MM - DD to represent the date and HH:MM:SS for the time.
Pages:
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137