Working on a clock, very simple stuff:
onClipEvent (enterFrame) { time = new Date(); mil = time.getMilliseconds(); s = time.getSeconds(); m = time.getMinutes(); h = time.getHours(); seconds._rotation = s*6+(mil/(1000/6)); minutes._rotation = m*6+(s/10); hours._rotation = h*30+(m/2); }
How do i get it to display a different time zone?
Found this:
public static function getTimezone():Number { // Create two dates: one summer and one winter var d1 : Date = new Date( 0, 0, 1 ) var d2 : Date = new Date( 0, 6, 1 )
// largest value has no DST modifier var tzd:Number = Math.max( d1.timezoneOffset, d2.timezoneOffset )
// convert to milliseconds return tzd * 60000 }
public static function getDST( d : Date ):Number { var tzd : Number = getTimezone() var dst : Number = (d.timezoneOffset * 60000) - tzd return dst }
OK, I get how to add offsets. Let me rephrase the question:
I have to create a single application with a set of 3 clocks, one for EST, one for Central, one for Pacific Time.
The application will be viewed by users in each of these time zones.
I need to be able to display variance from GMT so the time displays accurately regardless of the user's time zone...
so how do I call GMT?
Date.timezoneOffset gives you the number of minutes between UTC and the time as described by the client's machine. My guess is that you would:
- figure out the local time,
- determine the timezone offset for each of the three timezones,
- create three clocks with an initial value defined by UTC,
- apply anoffset to each clock,
- profit
Maybe?
(caveat: Haven't tried this myself. Just off the top of my head.)
fyi: If you output a Date object as a string, you get something that follows this format: Day Mon DD HH:MM:SS TZD YYYY
TZD is the timezone offset for the local time relative to GMT.
For example, outputting new Date() gives me the following: Fri Apr 24 10:53:33 GMT-0400 2009
Being on EST, adding 4 hours will give me GMT.
I think. 
I used the UTC & just subtracted the hours offset. Seems to work fine. For example, Montreal time: onClipEvent (enterFrame) { time = new Date(); mil = time.getMilliseconds(); m = time.getMinutes(); h = time.getUTCHours()-4; yul_minutes._rotation = m*6+(s/10); yul_hours._rotation = h*30+(m/2); }
Thanks!