/    Sign up×
Community /Pin to ProfileBookmark

AM / PM switch in flash clock

Hi all,

I am designing 5 digital clocks with different timing of course through the below action script, and it is working great except Sydney and Tokyo, the problem is that it does not switch from PM to AM…it is only PM, below is the code of Sydney clock, and as for Tokyo I add +10.

Can you guys know what is wrong here ?
P.S : I place for New York : -3 for Cairo : +3 for London :+2, so do u think the reason for this issue of sydney and tokyo that the hour add is two digit ( above 10 )???

thanks in advance.

time=new Date(); // time object
var seconds = time.getUTCSeconds()
var minutes = time.getUTCMinutes()
var hours = time.getUTCHours()

[B][COLOR=”Red”]hours = hours +11;
[/COLOR]
[/B]

if (hours<12) {
ampm = “AM”;
}
else{
ampm = “PM”;
}
while(hours >12){
hours = hours – 12;
}
if(hours<10)
{
hours = “0” + hours;
}
if(minutes<10)
{
minutes = “0” + minutes;
}
if(seconds<10)
{
seconds = “0” + seconds;
}
clock_txt.text = hours + “:” + minutes + “:” + seconds +” “+ ampm;

to post a comment
Full-stack Developer

0Be the first to comment 😎

×

Success!

Help @Baracoda spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...