MCPcopy Create free account
hub / github.com/Go-Learning-Land/Go-Learning-Archive / main

Function main

GolangBasics/GoByExample/054TimeFormat.go:8–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6)
7
8func main() {
9 p := fmt.Println
10
11 t := time.Now()
12 p(t.Format(time.RFC3339))
13
14 t1, e := time.Parse(
15 time.RFC3339,
16 "2012-11-01T22:08:41+00:00")
17 p(t1)
18
19 p(t.Format("3:04PM"))
20 p(t.Format("Mon Jan _2 15:04:05 2006"))
21 p(t.Format("2006-01-02T15:04:05.999999-07:00"))
22 form := "3 04 PM"
23 t2, e := time.Parse(form, "8 41 PM")
24 p(t2)
25
26 fmt.Printf("%d-%02d-%02dT%02d:%02d:%02d-00:00\n",
27 t.Year(), t.Month(), t.Day(),
28 t.Hour(), t.Minute(), t.Second())
29
30 ansic := "Mon Jan _2 15:04:05 2006"
31 _, e = time.Parse(ansic, "8:41PM")
32 p(e)
33}

Callers

nothing calls this directly

Calls 2

PrintfMethod · 0.80
ParseMethod · 0.65

Tested by

no test coverage detected