Golang - time zone showing twice

When running this code, the result should show the date and zone

It's amazing that the result shows the time zone twice, and I can’t understand why

package main

import (
    "fmt"
    "time"
)

func main() {

    mytime, _ := time.Parse("02/Jan/2006:15:04:05 -0700", "07/Apr/2017:01:26:05 +0530")

    fmt.Println(mytime)

}

Result of this

2017-04-07 01:26:05 +0530 +0530

So my question is: why is the time zone displayed twice?

+4
source share
1 answer

fmt.Printlncalls a function Time .String()that returns time in the following format:

"2006-01-02 15:04:05.999999999 -0700 MST"

The codes you see contain both the time zone offset and the time zone name.

In your case, there is no time zone name known for time, so it gives the offset twice.

Literature:

+6
source

Source: https://habr.com/ru/post/1674240/


All Articles