V
V
vlarkanov2019-08-26 09:51:58
go
vlarkanov, 2019-08-26 09:51:58

How to get the desired time display?

time.Now() produces a string like

2019-08-26 09:47:09.557949552 +0300 MSK m=+4.752612985

How to crop it to look
2019-08-26 09:47:09

?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2019-08-26
@NeiroNx

Magic date and time instead of the usual "%d.%M.%Y %H:%M"

package main
import (
  "fmt";
  "time"
)
func main() {
  t, _ := time.Parse("2006-01-02 15:04:05", "2019-08-26 11:10:02");
  fmt.Println(t.Format("02.01.2006 15:04:05"))
}

26.08.2019 11:10:02

A
alfss, 2019-08-26
@alfss

https://programming.guide/go/format-parse-string-t...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question