Documentation
¶
Overview ¶
Package unixtime provides functions that make it easier to convert between go time.Time objects and Unix timestamps.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToTime ¶
ToTime converts an int64 representing the number of unit {nano,mirco,milli,}seconds since 1 January 1970 utc. to a time. This function has the same imput limitations as time.Unix. ToTime panics if your unix is something other than 1 {Nano,Micro,Milli}second.
Example ¶
var unixMilliseconds int64 = 1507156635642
t := ToTime(unixMilliseconds, time.Second)
fmt.Printf("time=%s\n", t.Format(time.RFC3339Nano))
func ToUnix ¶
ToUnix converts a time object to number of {Nano,Mirco,Milli,}seconds since 1 January 1970 utc. ToUnix panics if your unix is something other than 1 {Nano,Micro,Milli}second.
Example ¶
now := time.Now()
s := ToUnix(now, time.Second)
ms := ToUnix(now, time.Millisecond)
us := ToUnix(now, time.Microsecond)
fmt.Printf("seconds=%d milliseconds=%d microseconds=%d\n", s, ms, us)
Types ¶
This section is empty.