Digital world clock - HELP ME PLZ!

Hi there.

Can someone help me what i should do with this script so that i can run 2 cocks with a different time zone (Miami EST TIME & Frankfurt, EUROPE TIME).
I can find a lot of tutorials on Flashkit.com but all those are too complex and they have an analog script included.

IF someone can help that’d be awsome.
Dave


1st keyframe:

myDate = new Date();
dateTextField = (mydate.gethours()+":"+myDate.getMinutes()+":"+mydate.getSeconds());
if (myDate.getMinutes() < 10) {
dateTextField = (mydate.gethours()+":0"+myDate.getMinutes()+":"+mydate.getSeconds());
}
if (myDate.getSeconds() < 10) {
dateTextField = (mydate.gethours()+":"+myDate.getMinutes()+":0"+mydate.getSeconds());
}
if ((myDate.getMinutes() < 10) && (myDate.getSeconds() < 10)) {
dateTextField = (mydate.gethours()+":0"+myDate.getMinutes()+":0"+mydate.getSeconds());
}


2nd frame

gotoandplay(1);
}

All you really have to do is subtract (or add) time to the first figure and set that to a new variable.

Does that make sense to you? If not… I’ll try to come up with a better explination.

Well, if I am not mistaken doesn’t that script take the time off of the viewers computer. This means that whoever views it will see the time in their area.

I hope I am not mistaken, otherwise I made fool of myself.

PS: Frankfurt, Germany: Where my family is originally from=) Ok, I will stop rambling on about useless knowledge.

Nope. I think you’re right Beta… The method would be to grab the GMT and add or subtract from that, based upon location.

I’ll look up what the difference is in the morning and see what I can do with that script.

I know there is a getTimezoneOffset() feature in flash, but I have never used it so I am not sure of what it does.

Hey, lost!
Sprichst Du deutsch? my family is also from around Frankfurt, part still lives there…

And i think you’re right, as you don’t know where the user watching the 2 cLocks (i hope you didn’t leave that l out on purpose…lol) will be, if you really want to display Miami and Ffm, you’ll have to set that up based on GMT (aka UTC) time, not user clock time:
myDate = new Date;
trace(myDate.getTimezoneOffset()); //thanks, Mr.Moock…
etc…it seems a bit complicated, based on the value returned above , you’ll need to add or substract to right number to get Miami or Ffm time…

Hey eyezburg,

Ich spreche sehr kleines Deutsch. I was born and raised in Philadelphia, PA, but my family originally hails from Frankfurt.

That is some useful information too. I was thinking of working on a clock that had all the timezones (got all of them from the options in this very forum) in a dropdown menu and you can select which one you want. Now that I know that UTC is the way to go for that I will experiment more with it.

Hey, Ich kann auch ein bisschen Deutsch spechen, aber Ich hab’es vor zu lange nicht gesprochen, it that means anything. And can you give the link to Moock, Eyez? I find his site spectacularly impossible to navigate.

pom :asian:

Ilyas: Its choppy, but I think you said you also speak a little german, but you haven’t been speaking it long. Am I right?

That was the idea, yeah =)

Woo Hoo!

**** foreigners. :slight_smile:

Haha, Ironisch ertönen Sie meine Schwestern mag:P

English: Ironically you sound like my sisters | (they say the same thing)

OK alle zusammen, nachdem Deutsch geklaert wurde… can someone give me a script that will get from the internet the time. I thought about that that this might be a user time clock. However those others scripts what i found on the net were quite too complicate for me since they had all thise variables for the analog time included. I will check Mooks site. Thanks for that tip but if someone ever did this please help out with a script what i can copy/past/ GG

Ciao all
Dave

myDate2 = new Date();
dateTextField = (mydate2.gethours()+6+":"+myDate2.getMinutes()+":"+mydate2.getSeconds());
if (myDate2.getMinutes() < 10) {
dateTextField = (mydate2.gethours()+6+":0"+myDate2.getMinutes()+":"+mydate2.getSeconds());
}
if (myDate2.getSeconds() < 10) {
dateTextField = (mydate2.gethours()+6+":"+myDate2.getMinutes()+":0"+mydate2.getSeconds());
}
if ((myDate2.getMinutes() < 10) && (myDate.getSeconds() < 10)) {
dateTextField = (mydate2.gethours()+6+":0"+myDate2.getMinutes()+":0"+mydate2.getSeconds());
}

The problem with that script is that it shows the right time on YOUR computer. Someone viewing it from that area will see their time +6 hours like you have in your script.

I don’t know how to create a Universal clock script, other wise I would help. If I get any free time today I will see if I can whip one up for you. The keyword there is “IF”.

LOL…
@Dave: remember…what was it, Poland…? lol, bloody foreigners…:slight_smile:

@all of ya: not bad, quite a few words of German resisted the assault of alcohol on your braincells!
When i said, thanks Moock, that was not the site, it was the book, no download or cut’n’paste so far…Rumours have it he’s working on an MX version …

@lost: right, dude.

@steinberginc: with a nick’ like that, you’re requiered to speak German!
I don’t know if I’ll get the time to try’n code that, specially as I don’t need that right now and have little time enuff, ask sbeener, he’ll write that script in about 2 mins for ya, lol.

Work on what you got, and don’t use the fixed value (6) to add, instead do a check on the “myDate.getTimezoneOffset()” to return the gmt offset value, and this value needs then to be compared to the miami or ffm offset to work out the actual number to add/substract… makes sense?

Ok, here is a link to my non-military clock tutorial…

NON-MILITARY CLOCK TUTORIAL

Follow that link and follow the tutorial, the only difference will be replacing the code in the Layer “Actions” with this instead of what is on the tutorial…

function updateTime() {
	myTime = new Date();
	milliseconds = myTime.getUTCMilliseconds();
	seconds = myTime.getUTCSeconds().toString();
	while (seconds.length<2) {
		seconds = "0"+seconds;
	}
	minutes = myTime.getUTCMinutes().toString();
	while (minutes.length<2) {
		minutes = "0"+minutes;
	}
	hours = myTime.getUTCHours().toString();
	delete myTime;
	for (clock; (hours>=13); hours -= 12) {
	}
	for (clock; (hours == 0); hours=12) {
	}
}
stop();

That will return the Universal Time (I believe, I tested it out, and it works, but I don’t know what the universal time really should be)

To change the time according to time zone change this…

hours = myTime.getUTCHours().toString();

to this…

hours = (myTime.getUTCHours().toString())-4;//subtract or add hours

-4 is the code to get the time in my area, you can change that whatever you need. Of course you will have to have 3 different functions for the 3 different clocks, which is very inefficient, but it works. There is probably some way to optimize this, but I just don’t have the time to work on that.

<B>PS: The tutorial says written for MX, but I recently got a chance to try it in Flash 5 and it works in both, so if you use 5, don’t worry</B>

i came up with something that will get your computer time and then minus the difference to get gmt time…you could then add on to this the difference of time between GMT and the time where u want it to line up with…well heres the code…


_root.createTextField("clock",0,275,200,400,200);
_root.onEnterFrame=function(){
	myDate = new Date();
	hours = myDate.getHours()
	timeZone = myDate.getTimezoneOffset()/60
	gmt= (hours+timeZone);
	clock.text = gmt+" : "+myDate.getMinutes()+" : "+myDate.getSeconds();
}

Ok hope it helps…its a bit shorter than some… :slight_smile:

zu viele deutscher hier drinn!

war nur ein witz(nicht so lustig weis ich)

**** i think my german is kaput