Skip to content

time: parsing a time with UnixDate layout ignores time zone #11815

@mmb

Description

@mmb

Create two times that differ only by their time zone. They both return the same value for Unix timestamp even though they are not the same time.

Example:

package main

import "fmt"
import "time"

func main() {
    time1, _ := time.Parse(time.UnixDate, "Mon Jan 2 15:04:05 MST 2006")
    time2, _ := time.Parse(time.UnixDate, "Mon Jan 2 15:04:05 PST 2006")

    fmt.Println(time1.Unix())
    fmt.Println(time2.Unix())
}

Output:

1136214245
1136214245

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