Time format
examples/time-format/time_format.go
package main import ( "fmt" "time" ) func main() { t := time.Now() fmt.Println("Default format:", t) fmt.Println("Unix format: ", t.Format(time.UnixDate)) fmt.Println("RFC3339 format:", t.Format(time.RFC3339)) fmt.Println("My format: ", t.Format("Mon Jan 2 15:04:05 MST 2006")) fmt.Println("My format: ", t.Format("2006-01-02 15:04:05")) }
Default format: 2020-04-24 22:12:50.510675771 +0300 IDT m=+0.000032091 Unix format: Fri Apr 24 22:12:50 IDT 2020 RFC3339 format: 2020-04-24T22:12:50+03:00 My format: Fri Apr 24 22:12:50 IDT 2020 My format: 2020-04-24 22:12:50