How to make a text display your time

Hi, so im making a text label say the players current time, and I’ve got the part where I get the time, but I don’t know how to format it. Someone please help!

local now = DateTime.now()
local minutesnow = now:ToLocalTime().Minute
print(now)
print(minutesnow)

this prints
image

never used DateTime but this should work:

local TimeNow = DateTime.now()
local LocalTime = TimeNow:ToLocalTime()
print("Current Time: "..LocalTime.Hour..":"..LocalTime.Minute..":"..LocalTime.Second)
1 Like

Thank you, but do you know how to convert it to standard display??

For example, if the time right now is 2 pm, the thing shows 14pm. How do I fix this?

print(DateTime.now():FormatLocalTime("LTS", "en-us"))

First argument for FormatLocalTime is the format, and the second is the locale.
You can find a list of these in this article

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.