I read here https://pkg.go.dev/time#Unix that Unix() returns the local Time corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC
And you can also get the milliseconds since, or nanoseconds since 1970 using UnixNano() and UnixMilli() respectively.
I guess I'm confused as to how this is safe. Won't there be a date/time cut off where the number of nano, milli or regular seconds exceeds int64's capacity?
Also, I was experimenting on go playground https://go.dev/play/ by printing out time.Now.Unix()
, I would always get 1257894000 seconds, even if I ran my code like a minute apart.
However I did see a difference if I did
time.Now.Unix()
time.Sleep(time.Duration(1) * time.Second)
time.Now.Unix()
Which gave me 1257894000 and 1257894001.
I'm confused how Unix time works basically.