Skip to content

Instantly share code, notes, and snippets.

@sanae10001
Created June 8, 2020 05:03
Show Gist options
  • Save sanae10001/f360b207ea5fbf6b41ff95f06d771823 to your computer and use it in GitHub Desktop.
Save sanae10001/f360b207ea5fbf6b41ff95f06d771823 to your computer and use it in GitHub Desktop.
Function to convert a Unix Millisecond Epoch Timestamp to time.Time(https://github.com/Tigraine/go-timemilli)
package timemilli
import "time"
const millisInSecond = 1000
const nsInSecond = 1000000
// Converts Unix Epoch from milliseconds to time.Time
func FromUnixMilli(ms int64) time.Time {
return time.Unix(ms/int64(millisInSecond), (ms%int64(millisInSecond))*int64(nsInSecond))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment