golang’s time package: seconds, milliseconds, nanoseconds timestamp output

The 10-digit timestamp is in seconds;
The 13-digit timestamp is in milliseconds;
The 19-digit timestamp is in nanoseconds;

package main
import (
func main() {
fmt.Printf("Time stamp (seconds): %v;\n", time.Now().Unix())
fmt.Printf("Time stamp (nanosecond): %v;\n", time.Now().UnixNano())
fmt.Printf("Time stamp (milliseconds): %v;\n", time.Now().UnixNano() / 1e6)
fmt.Printf("time stamp (convert nanoseconds to seconds): %v;\n", time.Now().UnixNano() / 1e9)

The output is:

Timestamp (seconds): 1530027865;
Timestamp (nanoseconds): 1530027865231834600;
Timestamp (milliseconds): 1530027865231;
Timestamp (nanoseconds to seconds): 1530027865

Leave a Reply

Your email address will not be published. Required fields are marked *