A
A
alst1612016-08-16 19:26:19
go
alst161, 2016-08-16 19:26:19

How to parse time in Go?

input date 16-08-2016 15:11:06. What template should be specified for the time.Parse function?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2016-08-16
@alst161

https://play.golang.org/p/OBLMayfjDc

O
Oleg Shevelev, 2016-08-18
@mantyr

alst161 : you can also look at the library https://github.com/mantyr/newtime , especially for coding in a more familiar way. Inside time and a number of functions for working in an object style.
For example like this:

package main

import (
    "github.com/mantyr/newtime"
    "fmt"
)

func main() {
    date := newtime.NewTime()
    date.Parse("16-08-2016 15:11:06", "dd-mm-yyyy HH:ii:ss")
    fmt.Println(date.Format("YYYY-mm-dd HH:ii:ss"))  // "2016-08-16 15:11:06"
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question