|
Advertisement |
Getting time unit values
Flash Player 9 and later, Adobe AIR 1.0 and later
You can extract the values for various units of time within a Date object using properties or methods of the Date class.
Each of the following properties gives you the value of a time unit in the Date object:
• The fullYear property
• The month property, which is in a numeric format with 0 for January up to 11 for December
• The date property, which is the calendar number of the day of the month, in the range of 1 to 31
• The day property, which is the day of the week in numeric format, with 0 standing for Sunday
• The hours property, in the range of 0 to 23
• The minutes property
• The seconds property
• The milliseconds property
In fact, the Date class gives you a number of ways to get each of these values. For example, you can get the month
value of a Date object in four different ways:
• The month property
• The getMonth() method
• The monthUTC property
• The getMonthUTC() method
All four ways are essentially equivalent in terms of efficiency, so you can use whichever approach suits your
application best.
The properties just listed all represent components of the total date value. For example, the milliseconds property
will never be greater than 999, since when it reaches 1000 the seconds value increases by 1 and the milliseconds
property resets to 0.
Share This
0 comments: