Skip to content

time: uninitialized time object produce unexpected conversion for trying to convert timezone with "func (t Time) In(loc *Location) Time"  #8550

@gopherbot

Description

@gopherbot

by nash.tsai:

What does 'go version' print?
go version go1.3.1 darwin/amd64

What happened?

package main

import (
    "time"
)

func main() {
    var t time.Time
    println ("t:", t.String(), "t in Local:", t.In(time.Local).String())
}

output:
t: 0001-01-01 00:00:00 +0000 UTC t in Local: 0001-01-01 08:26:44 +0826 LMT

What should have happened instead?

My timezone is +8 so I would expect:  "0001-01-01 08:00:00 +0800"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions