Skip to content

Instantly share code, notes, and snippets.

@kidtronnix
Created July 23, 2015 00:25
Show Gist options
  • Save kidtronnix/68a1c4f8ce968728db45 to your computer and use it in GitHub Desktop.
Save kidtronnix/68a1c4f8ce968728db45 to your computer and use it in GitHub Desktop.
Example of how to get timestamp from v1 UUID in GOLANG
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