How to Convert Back to a UTC Date on AS3
- 1). Create a new ActionScript 3.0 file in Flash by selecting "File/New."
- 2). Use the Type tool to draw a text field in the middle of the stage. Select the text field and enter "date" as the instance name in the Properties panel. Click the "Show Border Around Text" icon.
- 3). Enter the following code:
var dat:Date = new Date();
date.text = ""+dat;
date.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler);
function fl_MouseOverHandler(event:MouseEvent):void{
date.text = String("UTC:"+dat.getUTCFullYear()+"-"+ dat.getUTCMonth()+"-"+dat.getUTCDate()+" "+dat.getUTCHours()+":"+dat.getUTCMinutes()+":"+dat.getUTCSeconds());
}
date.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler);
function fl_MouseOutHandler(event:MouseEvent):void{
date.text = ""+dat;
} - 4). Test the movie by selecting "Controls/Test Movie." Standard GMT date and time will be displayed in the text field. Place the mouse cursor over the text field and the UTC date and time will be displayed. Move the mouse out of the text field and the field will display GMT again.