View Single Post
  #1 (permalink)  
Old 07-23-2008, 08:56 PM
welling1977
 
Posts: n/a
Diggs:
Default Need to display another timezone at 12hr not 24hr.

I have a clock that displays the month, day, time (i.e. Jul. 23, 21:34p) but is
set to another time zone. However, with my current code the time is on a 24hr
clock and i need it to be on a 12hr one. Plus I need the time change to also be
reflected in the day and month rather than just the time. any idea how to do
this????

var dayText:String;
var dateText:String;
var monthText:String;
var AmPm:String;
_root.onEnterFrame = function() {
var myDateate = new Date();
var min:Number = myDate.getMinutes();
//the +12 is the current time plus 12 hours to be the new timezone
var hour:Number = myDate.getHours()+12;
var day:Number = myDate.getDay();
var date:Number = myDate.getDate();
var month:Number = myDate.getMonth();
min = min<10 ? "0"+min : min;

//AM/PM
if (hour>12) {
hour = hour-12;
AmPm = "p";
} else {
AmPm = "a";
}

//day
{
dateText = date+"";
}

//month
if (month == 0) {
monthText = "Jan";
} else if (month == 1) {
monthText = "Feb";
} else if (month == 2) {
monthText = "Mar";
} else if (month == 3) {
monthText = "Apr";
} else if (month == 4) {
monthText = "May";
} else if (month == 5) {
monthText = "Jun";
} else if (month == 6) {
monthText = "Jul";
} else if (month == 7) {
monthText = "Aug";
} else if (month == 8) {
monthText = "Sep";
} else if (month == 9) {
monthText = "Oct";
} else if (month == 10) {
monthText = "Nov";
} else if (month == 11) {
monthText = "Dec";
}

//display
//dateDisplay.text = hour+":"+min+ AmPm + "-" + monthText+"."+ dateText; };

dateDisplay.text = monthText+". "+ dateText+ ", "+ hour+":"+min+ AmPm; };



Reply With Quote
Sponsored Links