Flash actionscript 3.0: how to get he System time in action script 3.0

how to get he System time in action script 3.0

Posted by Sankar.G | Posted in | Posted on 12:27 PM

you can get the system in action script 3.0 code is follows

import flash.utils.*;
var ti:Timer=new Timer(1000);
function fun(e:Event)
var a:Date=new Date();
str = "PM"
str = "AM"
t1_txt.text=Number(a.getHours()).toString()+":"+Number(a.getMinutes()).toString()+":" +Number(a.getSeconds()).toString()+" "+str;

for this we want to import a library utils
and declare a variable t1 as a timer and 1000 is milliseconds timer will tick per second if you set 500 it will 2 times for a second and addeventlistener for that timer and start the timer
and we declare a variable a as date
and use gethour ,get minutes, get seconds is used to get the system times

Comments (3)

good post!

this is really helpful.
How would you show the leading zero? For example, right now it displays 11:23:9, instead of 11:23:09

How would you ad AM/PM?


I update the postm Now you can get AM or PM easily