How can i make the clock include the zeros?s

I want to make a clock in my roblox game, issue is it displays time like “12:5” instead of “12:05”

local Date = DateTime.now():ToLocalTime() local Format = Date.Hour..":"..Date.Minute print(Format)

Is what im doing right now. I could proabably come up with something, but i dont want to do anything over complicated.

1 Like

ex:

if Date.Minute <= 10 then
   local Format = Date.Hour.. ":" .. "0" .. Date.Minute
end
3 Likes

ok thanks for the help mans
char limit

1 Like

string.format

string.format("%02d",2) -> 02
string.format("%05d",2) -> 00002

It works like printf in C

You can also use string.rep('0',desired length-#minute)..minute
But your method is better
(Sorry I’m typing this on phone)