Hello! I am pretty confused on the wiki page for DateTime. There is a property of date time called DateTime.UnixTimestampMillis
, which to my understanding returns the amount of milliseconds that passed before some date in the 1400’s. If I try to print this, it returns nil
, and the wiki page doesn’t show how you would use it, only what the property is. The only thing that may make sense is using this with DateTime.fromUnixTimestampMillis
, but how would I do that? Thanks
DateTime.now().UnixTimestampMillis
Oh I feel like an idiot now, thank you for this
Hey one more question, when trying to divide to get the minutes, the script outputs ServerScriptService.CommandHandler:48: attempt to perform arithmetic (sub) on number and Instance
, do you know how to fix this? I also used tonumber()
Edit: Script incase you need it:
local chosenPlayer = game.Players:FindFirstChild(split[2])
if chosenPlayer then
print(chosenPlayer.UserId)
local playerTime = chosenPlayer.ServerTime
local nowTime = DateTime.now().UnixTimestampMillis
print(string.format("%d:%.02d:%.03d", tonumber(nowTime)/3600000 - playerTime.Value/3600000, tonumber(nowTime)/60000 - playerTime.Value/60000, tonumber(nowTime) - playerTime))
chosen player is found via :FindFirstChild(), and the value is also DateTime,now().UnixTimestampMillis
, and that saves the milliseconds number!
I think the issue may be here, did you forget to put .Value
after playerTime
?
Oh didn’t notice that lmao, thank you for this
1 Like