How to format a number to date?

The title already says my problem, I don’t know how to convert a number value to date (I need to save that number value in a datastore, and then load it to convert it to date format for the player gui)

local data=DateTime.now() --number (to save it)
print(data:FormatLocalTime("MM/DD/YY (HH:mm)","en-us")) --date format

Thanks in advance!

Use local nowMs = DateTime.now().UnixTimestampMillis to get a number and DateTime.fromUnixTimestampMillis(nowMs) to convert it back into a DateTime (which you can call FormatLocalTime on)

Thank you! I didn’t know that Unix could be obtained like that haha

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