Display current time

420 views
Skip to first unread message

matiasx

unread,
Dec 17, 2008, 12:43:39 AM12/17/08
to Flex India Community
Hi all,

I need to show the current time in my browser. I try with new Date,
but that's a static time y need my system. I need my time show current
system time, like windows tray bar.

Thanks in advance.

Matias

Prasanth

unread,
Dec 17, 2008, 11:34:14 PM12/17/08
to Flex India Community
Hi ..


I think the below posted code shld help you .Bind the time variable
to a label where you want to display the time and call the showTime
function on creation complete of the application. Hope this helps

private var ticker:Timer;
[Bindable] private var time:String;

public function showTime():void
{
var currentTime:Date = new Date();
time=timeFormat.format(currentTime);
ticker = new Timer(1,1);
ticker.addEventListener(TimerEvent.TIMER_COMPLETE,
onTimerComplete);
ticker.start();
}

public function onTimerComplete(event:TimerEvent):void{
showTime();
}


Thanks
Prasanth

matiasx

unread,
Dec 18, 2008, 12:28:45 AM12/18/08
to Flex India Community
Great!

Big hug!

On 18 dic, 01:34, Prasanth <mailspark1...@gmail.com> wrote:
> Hi ..
>
>  I think the below posted code shld help you .Bind the time variable
> to a label where you want to display the time and call the showTime
> function on creation complete of the application. Hope this helps
>
>         private var ticker:Timer;
> [Bindable] private var time:String;
>
>                 public function showTime():void
>             {
>                    var currentTime:Date = new Date();
>                            time=timeFormat.format(currentTime);
>                            ticker = new Timer(1,1);
>                            ticker.addEventListener(TimerEvent.TIMER_COMPLETE,
> onTimerComplete);
>                        ticker.start();
>             }
>
>             public function onTimerComplete(event:TimerEvent):void{
>                   showTime();
>              }
>
> Thanks
> Prasanth

Thalai raju

unread,
Dec 18, 2008, 6:25:13 AM12/18/08
to flex_...@googlegroups.com
hi matiasx
                can you get current date and after you can get current time  using gettime()

 

rjoshicool

unread,
Dec 24, 2008, 5:55:49 AM12/24/08
to Flex India Community
I tried it but it didn't work for me. it is not able to recognize
timeFormat.. any solution??

On Dec 18, 4:25 pm, "Thalai raju" <grajesh.go...@gmail.com> wrote:
> hi *matiasx*
>                 can you get current date and after you can get current time
> using gettime()
>

Venkat Viswanathan

unread,
Dec 24, 2008, 12:38:39 PM12/24/08
to flex_...@googlegroups.com
Hi,

Add these two lines above the timeFormat.format () line...

var timeFormat:DateFormatter = new DateFormatter;
timeFormat.formatString = "HH:NN:SS" //"KK:NN:SS" for 12hr clock

Regards,
Venkat
www.venkatv.com

HISSAM

unread,
Dec 24, 2008, 2:32:11 PM12/24/08
to flex_...@googlegroups.com
change this line to

  time=timeFormat.format(currentTime);

                  TO

time=currentTime.hours+":"+currentTime.minutes+":"+currentTime.seconds;
Reply all
Reply to author
Forward
0 new messages