Last active
December 16, 2015 15:29
-
-
Save kisom/5456138 to your computer and use it in GitHub Desktop.
It appears time.Now().UTC().Unix() still returns a local timestamp. If this doesn't work, I'm not sure how to get a UTC timestamp.
This file contains 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" | |
import "time" | |
func main() { | |
local, _ := time.Now().Zone() | |
fmt.Println("Local timezone:", local) | |
fmt.Println("UNIX local timestamp:", time.Now().Unix()) | |
fmt.Println("UNIX UTC timestamp:", time.Now().UTC().Unix()) | |
} |
This file contains 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
$ go version | |
go version devel +d4c3e6c8b141 Wed Apr 24 10:40:29 2013 -0700 darwin/amd64 | |
$ go run timestamp.go | |
Local timezone: MDT | |
UNIX local timestamp: 1366842519 | |
UNIX UTC timestamp: 1366842519 |
This file contains 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
$ go version | |
go version devel +ce5b441d2fc6 Sun Apr 14 09:22:57 2013 +1000 linux/amd64 | |
$ go run timestamp.go | |
Local timezone: MDT | |
UNIX local timestamp: 1366843096 | |
UNIX UTC timestamp: 1366843096 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment