A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: World Time Zone

  1. #1
    Senior Member
    Join Date
    Oct 2000
    Posts
    474

    World Time Zone

    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;
    }

  2. #2
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    instead of returning it, say myTextField.text = h+":"+m+":"+s;
    where myTextField is the name of the textfield...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center