Hi,
I need to put different world time zones in my mc. I found the below code that generates time zones based on UTC time.
It traces the right time but how can I add the trace output to a dynamic textfield?
Thanks for your assistance, as3 is still driving me bezerk ;-)
Code:// Create a local Date object. var local: Date = new Date(); // Create a UTC Date object. var utc: Date = new Date(local.getTime() + (local.getTimezoneOffset() * 60000)); // Get a UTC timestamp. var utcTime:Number=utc.getTime(); // Now do the other calculations based on the UTC timestamp. var uk:Number = utcTime + (0); var newyork:Number = utcTime + ((3600000) * -5); var moscow:Number = utcTime + ((3600000) * 3); var ukDate:Date=new Date(uk); var newyorkDate:Date=new Date(newyork); var moscowDate:Date=new Date(moscow); // trace(buildTime(ukDate) ); trace( buildTime(newyorkDate) ); trace( buildTime(moscowDate) ); function buildTime(date: Date):String { var h:String=String(date.getHours()); var m:String=String(date.getMinutes()); var s:String=String(date.getSeconds()); if (h.length==1) { h="0"+h; } if (m.length==1) { m="0"+m; } if (s.length==1) { s="0"+s; } return h + ":" + m + ":" + s; }


Reply With Quote