Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Jul 23, 2015 Jul 23, 2015

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?

TOPICS
ActionScript
963
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 25, 2015 Jul 25, 2015

currDate.time, not currDat.milliseconds.

Translate
Community Expert ,
Jul 23, 2015 Jul 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 24, 2015 Jul 24, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 24, 2015 Jul 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 25, 2015 Jul 25, 2015

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=f7bee07a7e79c8f1d7951b4d24de4713c22f140...

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2015 Jul 25, 2015

currDate.time, not currDat.milliseconds.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 25, 2015 Jul 25, 2015

Thank you!!! Now it works!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2015 Jul 25, 2015
LATEST

you're welcome.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines