Getting Epoch Time
Usetime.Now with Unix, UnixMilli, or UnixNano to get elapsed time since the Unix epoch:
Seconds Since Epoch
Milliseconds Since Epoch
Nanoseconds Since Epoch
Converting Epoch to Time
Convert integer seconds or nanoseconds since the epoch into the correspondingtime:
From Seconds
From Nanoseconds
Epoch Time Methods
Returns the number of seconds since January 1, 1970 UTC
Returns the number of milliseconds since January 1, 1970 UTC
Returns the number of nanoseconds since January 1, 1970 UTC
Creates a Time from seconds and nanoseconds since the epoch
Use Cases
Timestamps
Store and compare event times
APIs
Exchange timestamps with external systems
Logging
Record when events occurred
Caching
Calculate expiration times
Time Formatting
Learn how to format and parse time values