How can I translate this code from Python to Go?
>>> from time import gmtime
>>> from time import strftime
>>> strftime("%z", gmtime())
'-0800'
I tried:
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println(time.Now().Local().Format("-0700"))
}
But it's obviously not working:
+0000
I am somewhat confused in general about the formatting part of time because the const symbols (e.g. stdNumTZ
) are not exported from the time
package.
Is time.Now().Local()
in Go the real substitute for gmtime.gmtime()
in Python?