Share your repls and programming experiences

← Back to all posts
Digital 24 hour clock! Modified code from
SilentSerenity (1)

Digital 24 hour Clock

Credits go to, who made the original code.

Modifications I made to this:

Changed the color from the orange background to a purple background

Changed the text color of the digits to a darker purple to match

Changed the background to my Starry Background (I drew that myself)

Biggest modification, I converted this into a 24-hour clock!

Once again all credits go to @tussiez , and I hope they like this ^^

tussiez (1527)

Nice! It is just different colors really, lol :D

SilentSerenity (1)

@tussiez and then the 24 hr time... idk what time it is for you rn but it will go into 13 - 24 in the afternoon ^-^

tussiez (1527)

@SilentSerenity That is pretty easy, just cut out the if statement that changes >12

SilentSerenity (1)

ah, how i did it is that i just simply changed the "if hour > 12" to "if hour > 24" (line 103 on mine here, then refers to 115 on yours), then I inserted a statement to make a 0 appear before the hours before 10 on line 114. Then finally I added an extra "8" on line 111 on this code here, to accommodate the extra 0 to appear before the double digit hours. (hopefully that was good detail haha, pretty interesting stuff)

tussiez (1527)

@SilentSerenity Actually, my code from here is pretty bad (I just started then), so a lot of this could've been compressed into a few lines, e.g some if statements could just become ternary operators:

if(hours > 12){
hours -= 12;
// could just be:
hours = hours > 12 ? hours-12 : hours;

// minutes:
if(minutes < 10) {minutes = '0' + 10}

// can be:
minutes = minutes < 10 ? '0'+minutes : minutes;