在Go中,在尝试将字符串转换time.Time为时,使用时间包的Parse方法不会返回预期结果.似乎问题在于时区.我想更改为ISO 8601以及UTC中的日期和时间.
package main
import (
"fmt"
"time"
)
func main() {
const longForm = "2013-05-13T18:41:34.848Z"
//even this is not working
//const longForm = "2013-05-13 18:41:34.848 -0700 PDT"
t, _ := time.Parse(longForm, "2013-05-13 18:41:34.848 -0700 PDT")
fmt.Println(t)
//outputs 0001-01-01 00:00:00 +0000 UTC
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!