On Tue, Jul 11, 2017 at 12:34 PM, xiaolan via golang-nuts
<golang-nuts@googlegroups.com> wrote:
>
> The following time "t" is at PST time zone. However, after I ran this code,
> the  fmt.Println(t.Format(time.RFC3339))  gives me
>
> 2013-02-03T19:54:00Z
>
> which is UTC zone. I would expect it to be -07:00.
>
> const longForm = "Jan 2, 2006 at 3:04pm (MST)"
> t, _ := time.Parse(longForm, "Feb 3, 2013 at 7:54pm (PST)")
> fmt.Println(t)
>
> fmt.Println(t.Format(time.RFC3339))
> fmt.Println(t.Zone())
>
> Now sure which goes wrong. See complete code at
> https://play.golang.org/p/jSgOlIWeXk

Zone abbreviations are hard to work with.  The playground behaves as
it does because PST is unrecognized.  The effect is to get a time that
is marked as PST with an offset of 0 (see "If the zone abbreviation is
unknown" in https://golang.org/pkg/time/#Parse).  When printing with
time.RFC3339, an offset of 0 is printed as Z.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to