Adding time zone hours difference to time

Posted by Hwang on Stack Overflow See other posts from Stack Overflow or by Hwang
Published on 2010-04-23T03:05:10Z Indexed on 2010/04/23 3:13 UTC
Read the original article Hit count: 369

Filed under:
|
|

I know there's a much better and correct way to do it, but i need a temporarily solutions. I need to add in extra hours to the time, and the day will change automatically too. How should I change the code below?

package {
public class getTime {
    private var today:Date=new Date();
    private var hour:uint=today.getHours();
    private var minute:uint=today.getMinutes();
    private var month:uint=today.getMonth();
    private var monthArray:Array=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
    private var time:String = getUSClockTime(today.getHours(), today.getMinutes());
    public var dateNtime:String=(time+", " +today.getDate()+" "+monthArray[month]+" "+today.getFullYear());;

    public function getTime() {
    }

    private function getUSClockTime(hrs:uint, mins:uint):String {
        var modifier:String="PM";
        var minLabel:String=doubleDigitFormat(mins);

        if (hrs>12) {
            hrs=hrs-12;
        } else if (hrs == 0) {
            modifier="AM";
            hrs=12;
        } else if (hrs < 12) {
            modifier="AM";
        }

        return (doubleDigitFormat(hrs) + ":" + minLabel + " " + modifier);
    }

    private function doubleDigitFormat(num):String {
        if (num<10) {
            return ("0" + num);
        }
        return num;
    }
}
}

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about gettime