{"id":1287,"date":"2020-02-01T06:44:24","date_gmt":"2020-02-01T06:44:24","guid":{"rendered":"https:\/\/golangbyexamples.com\/?p=1287"},"modified":"2020-02-01T06:44:32","modified_gmt":"2020-02-01T06:44:32","slug":"date-in-golang","status":"publish","type":"post","link":"https:\/\/golangbyexamples.com\/date-in-golang\/","title":{"rendered":"Date in Go (Golang)"},"content":{"rendered":"\n
Date in Go is represented using time.Time <\/strong>struct only. There is no separate Date struct in Go. time.Date<\/strong> function can be used to construct a date. This function returns the time which is yyyy-mm-dd hh:mm:ss + nsec<\/strong> nanoseconds with the appropriate time zone corresponding to the given location. The signature of the function is:<\/p>\n\n\n\n As can be seen from the signature the arguments to the function are<\/p>\n\n\n\n Some points worth noting about time.Date<\/strong> function<\/p>\n\n\n\n Let’s see a working example:<\/p>\n\n\n\n Output:<\/strong><\/p>\n\n\n\n Date in Go is represented using time.Time struct only. There is no separate Date struct in Go. time.Date function can be used to construct a date. This function returns the time which…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"class_list":["post-1287","post","type-post","status-publish","format-standard","hentry","category-tech"],"yoast_head":"\nfunc Date(year int, month Month, day, hour, min, sec, nsec int, loc *Location) Time<\/code><\/pre>\n\n\n\n
package main\n\nimport (\n \"fmt\"\n \"time\"\n)\n\nfunc main() {\n t := time.Date(2021, time.Month(2), 21, 1, 10, 30, 0, time.UTC)\n fmt.Println(t)\n}<\/code><\/pre>\n\n\n\n
2021-02-21 01:10:30 +0000 UTC<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"