DateTime.now() is a constructor for a DateTime object. When printed, the object gets serialized to it’s UnixTimestampMillis, similar to how printing a part serializes the part’s name into output. The datetime object is not equivalent to it’s UnixTimestampMillis, and neither is a part equivalent to it’s name.
I’m not sure what the redundancy is here, but there may be a case for serializing the log output for DateTime objects to not appear as a number. I know that this confused me early on when I was messing with them.
Maybe I didn’t make myself clear about something very simple:
If I want to get the current timestamp with milliseconds, I can either use DateTime.now().UnixTimestampMillis or simply DateTime.now().
It is to this redundancy that I am referring.
DateTime.now() gives you a DateTime object which you can do other operations with. It will print it’s milliseconds when logged, but it is not equivalent to that number. These are not the same.
Is this redundant? The code I’ve written is redudnant, but the implementation is not. print(workspace, workspace.Name)
Workspace Workspace
Is there a specific place in the documentation that is redundant? I’m not sure exactly what the issue is.
Sorry, you’re right.
I won’t be able to do math operations directly with DateTime.now(). For example: print(DateTime.now()/1000) will produce:
attempt to perform arithmetic (div) on DateTime and number
So the correct thing is to use DateTime.now().UnixTimestampMillis.
However, since this has caused all this confusion, I will leave this topic open for the Roblox team to consider making this clearer in the current documentation.
Thanks for flagging this. I’ve drafted a small change to the references here to make this more clear in the future. This change is expected to land some time next week in our documentation update.
Appreciate you helping make our docs more clearer for our community! Have a great day .