03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example<br />

The following example initially creates a new Date object, setting the time <strong>and</strong> date to<br />

8:00:00 a.m. on May 15, 2004, <strong>and</strong> uses Date.setSeconds() to change the time to 8:00:45<br />

a.m.:<br />

var my_date:Date = new Date(2004,4,15,8,0,0);<br />

trace(my_date.getSeconds()); // output: 0<br />

my_date.setSeconds(45);<br />

trace(my_date.getSeconds()); // output: 45<br />

setTime (Date.setTime method)<br />

public setTime(millisecond:Number) : Number<br />

Sets the date for the specified Date object in milliseconds since midnight on January 1, 1970,<br />

<strong>and</strong> returns the new time in milliseconds.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 5<br />

Parameters<br />

millisecond:Number - A number; an integer value where 0 is midnight on January 1,<br />

universal time.<br />

Returns<br />

Number - An integer.<br />

Example<br />

The following example initially creates a new Date object, setting the time <strong>and</strong> date to 8:00<br />

a.m. on May 15, 2004, <strong>and</strong> uses Date.setTime() to change the time to 8:30 a.m.:<br />

var my_date:Date = new Date(2004,4,15,8,0,0);<br />

var myDate_num:Number = my_date.getTime(); // convert my_date to<br />

milliseconds<br />

myDate_num += 30 * 60 * 1000; // add 30 minutes in milliseconds<br />

my_date.setTime(myDate_num); // set my_date Date object 30 minutes forward<br />

trace(my_date.getFullYear()); // output: 2004<br />

trace(my_date.getMonth()); // output: 4<br />

trace(my_date.getDate()); // output: 15<br />

trace(my_date.getHours()); // output: 8<br />

trace(my_date.getMinutes()); // output: 30<br />

Date 503

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!