Copy link to clipboard
Copied
I have a flash file that has a built in clock. I would like the clock to function on a 12 hour schedule instead of a 24 hour or military one.
Any help would be greatly appreciated!
Here is the code:
onClipEvent (enterFrame) {
now = new Date();
switch (now.getMonth()) {
case 0:
month = "January";
break;
case 1:
month = "February";
break;
case 2:
month = "March";
break;
case 3:
month = "April";
break;
case 4:
month = "May";
break;
case 5:
month = "June";
break;
case 6:
month = "July";
break;
case 7:
month = "August";
break;
case 8:
month = "September";
break;
case 9:
month = "October";
break;
case 10:
month = "November";
break;
case 11:
month = "December";
break;
default:
trace ("")
}
switch (now.getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
break;
default:
trace ("")
}
minutes = now.getMinutes();
if (minutes <=9 && minutes >=0)
{
minutes = "0"+now.getMinutes();
}
seconds = now.getSeconds();
if (seconds <=9 && seconds >=0)
{
seconds = "0"+now.getSeconds();
}
date1 =day +","+ month +","+ now.getDate();
date2 =now.getHours() + ":" + minutes;
}
Thanks!
Replace:
date2 =now.getHours() + ":" + minutes;
With:
var hour = now.getHours();
if(hour == 0){
hour = 12
} else if(hour > 12){
hour -= 12
}
date2 =hour + ":" + minutes;
Copy link to clipboard
Copied
Replace:
date2 =now.getHours() + ":" + minutes;
With:
var hour = now.getHours();
if(hour == 0){
hour = 12
} else if(hour > 12){
hour -= 12
}
date2 =hour + ":" + minutes;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now