Created
July 23, 2015 00:25
-
-
Save kidtronnix/68a1c4f8ce968728db45 to your computer and use it in GitHub Desktop.
Example of how to get timestamp from v1 UUID in GOLANG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
"github.com/pborman/uuid" | |
) | |
func main() { | |
id := uuid.NewUUID() | |
t, _ := id.Time() | |
sec, nsec := t.UnixTime() | |
timeStamp := time.Unix(sec, nsec) | |
fmt.Printf("Your unique id is: %s \n", id) | |
fmt.Printf("The id was generated at: %v \n", timeStamp) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment