- Home /
Timestamp and Date from Unity? for mobile
Is it possible to return the timestamp and or datetime from Unity?
In search, it seems the only approach is by polling a webserver for datetime... That seems redundant, especially since timestamp is available on Android
Comment
System.DateTime.Now.ToString("yyyy$$anonymous$$$$anonymous$$ddHHmmssffff")
Answer by hojjat-reyhane · Jul 16, 2019 at 12:29 PM
For future searchers! This is how you get time as timestamp in Unity:
long time = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds();
It will give you something like this: 1563280100.
Tested in Unity 2019