Skip to content

Instantly share code, notes, and snippets.

@dherbst
Created April 12, 2019 13:40
Show Gist options
  • Save dherbst/c5813d8467cd6d984443e97c95e775e7 to your computer and use it in GitHub Desktop.
Save dherbst/c5813d8467cd6d984443e97c95e775e7 to your computer and use it in GitHub Desktop.
Golang time in a location
package main
import (
"fmt"
"time"
)
const PolicyDateFormat = "02-01-2006 15:04:05"
func main() {
location, err := time.LoadLocation("Europe/London")
if err != nil {
fmt.Printf("NewToken: error getting Europe/London time location err=%v\n", err)
return
}
d := time.Now().In(location)
fmt.Printf("%s\n", d.Format(PolicyDateFormat))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment