K
K
kolo20122017-04-02 07:17:02
go
kolo2012, 2017-04-02 07:17:02

How to get the date?

It was the first time I needed it. So I didn't understand how to do it. I need to get the current date in the format "3/29/2017". How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Leonid Nikolaev, 2017-04-02
@nikonor

t := time.Now().Format("1/2/2006")
t will be a string.

V
Vyacheslav, 2017-04-02
@Firik67

It can be something like this:

t := time.Now()
fmt.Printf("%d.%02d.%02dT\n", t.Year(), t.Month(), t.Day())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question