Skip to main content
Participating Frequently
July 23, 2015
Answered

How can I setup a UTC Time Zone in analog clock with actionscript 3?

  • July 23, 2015
  • 1 reply
  • 1084 views

I use this code from an YouTUBE tutorial:

addEventListener(Event.ENTER_FRAME, timehandler);

function timehandler(event:Event):void

{

  var currentdate:Date = new Date();

  second_hand.rotation = currentdate.seconds * 6

  minute_hand.rotation = currentdate.minutes * 6 + currentdate.seconds / 10;

  hour_hand.rotation = currentdate.hours * 30 + currentdate.minutes / 2;

}

And this clock work perfect, but how can I setup different Time Zone, not this one time zone on the computer?

This topic has been closed for replies.
Correct answer kglad

Thanks!

Now my code looks like this:

addEventListener(Event.ENTER_FRAME, timehandler);

function timehandler(event:Event):void

{

var currDate:Date=new Date();

var prevDate:Date=new Date(currDate.milliseconds-24*60*60*1000);

  second_hand.rotation = currDate.seconds * 6

  minute_hand.rotation = currDate.minutes * 6 + currDate.seconds / 10;

  hour_hand.rotation = prevDate.hours * 30 + currDate.minutes / 2;

}

But there is couple of problems:

1. First of all, when our time is 20:00 h with "-24" the clock show 14:00h (2:00h)???

2. I setup the value to "-17" for instance, then the clock show 19:00h (7:00h) and after the time become one hour ahead to 21:00h the clock begins again from 19:00 (7:00).

I can show the defect here (have to wait a few seconds while load the campaign):

http://pluto.signage.me/WebService/SignagePlayerApp.html?eri=f7bee07a7e79c8f1d7951b4d24de4713c22f140a56ba657d&playerPara…

I'm so sorry about this, but I'm not working with Flash and actionscript and this is so unusual case for me!


currDate.time, not currDat.milliseconds.

1 reply

kglad
Community Expert
Community Expert
July 23, 2015

you can use parameters in the Date constructor, but the Date class determines the current date from the users computer.  so users in different time zones (and users with mis-set computer times/dates) will see something different than you.

Participating Frequently
July 24, 2015

Thank you, kglad! That idea is perfect for me, but can you explain me where exactly i should put this parameters?

kglad
Community Expert
Community Expert
July 24, 2015

eg, for the date 24hrs previous (prevDate) to the current date (currDate):

var currDate:Date=new Date();

var prevDate:Date=new Date(currDate.time-24*60*60*1000);

p.s. there's also a timezoneOffset Date property that might help you.