For a clock widget, displaying Eastern Standard Time: onClipEvent (enterFrame) { myTime2 = new Date(); nSeconds2 = myTime2.getSeconds(); nMinutes2 = myTime2.getMinutes(); nHours2 = myTime2.getUTCHours()-5;
if (nHours2<=0) {
nHours2 = 24+nHours2;
}
if (length(nMinutes2) == 1) {
nMinutes2 = "0"+nMinutes2;
}
nTime2 = nHours2+":"+nMinutes2;
}
Works swell, except that 10 minutes after midnight displays as 24:10 - how would I get it to display 00:10 ?
onClipEvent (enterFrame) { myTime2 = new Date(); nSeconds2 = myTime2.getSeconds(); nMinutes2 = myTime2.getMinutes(); nHours2 = myTime2.getUTCHours()-5;
if (nHours2<=0) {
nHours2 = 24+nHours2;
if(nHours2==24){
nHours2 = "00";
}
}
if (length(nMinutes2) == 1) {
nMinutes2 = "0"+nMinutes2;
}
nTime2 = nHours2+":"+nMinutes2;
}
This is some ugly code, but my brain is n't working today to figre out a simple one liner that does everything at once. this should work.
I noticed you're looking for the double digit. you may also want to prepend a zero on your single integers. ?
At this point, functional is more important than pretty - seems to work. Cheers!
I had come up with pretty much the same but forgot an "=". Oops!
you can probably take time off the date and substring the toString but that would be rather ugly hacky one liner that since you have a solution is prob not worth working out.