Skip to content

time: want more control over time.Format #9547

@ddietterich

Description

@ddietterich

Using go version go1.3.3 linux/amd64

func main() {
        t := time.Now()
        fmt.Printf("time: %v; format: %s\n", t, t.Format("20080101 10:00:00.000"))
}

Prints:

time: 2015-01-09 17:06:02.033307544 +0000 UTC; format: 90080101 10:00:00.033

I want YYYYMMDD, but time.Format is only layout by example, so it cannot know what digits mean year, month, day. I have to do it by hand.

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