{"id":1186,"date":"2020-01-22T03:12:27","date_gmt":"2020-01-22T03:12:27","guid":{"rendered":"https:\/\/golangbyexamples.com\/?p=1186"},"modified":"2020-01-22T03:12:30","modified_gmt":"2020-01-22T03:12:30","slug":"dob-golang","status":"publish","type":"post","link":"https:\/\/golangbyexamples.com\/dob-golang\/","title":{"rendered":"Represent Date of Birth in Go (Golang)"},"content":{"rendered":"\n
time.Date<\/strong> function of time<\/strong> package can be used to create a particular date that can represent a DOB. See below example<\/p>\n\n\n\n Output:<\/strong><\/p>\n\n\n\n time.Date function of time package can be used to create a particular date that can represent a DOB. See below example getDOB is the function that takes in a year, month and…<\/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":[165,164,167],"class_list":["post-1186","post","type-post","status-publish","format-standard","hentry","category-tech","tag-date","tag-dob","tag-package"],"yoast_head":"\n
<\/p>\n\n\n\npackage main\n\nimport (\n \"fmt\"\n \"time\"\n)\n\nconst (\n \/\/TimeFormat1 to format date into\n TimeFormat1 = \"2006-01-02\"\n \/\/TimeFormat2 Other format to format date time\n TimeFormat2 = \"January 02, 2006\"\n)\n\nfunc main() {\n dob := getDOB(2011, 4, 2)\n fmt.Println(dob.Format(TimeFormat1))\n fmt.Println(dob.Format(TimeFormat2))\n}\n\nfunc getDOB(year, month, day int) time.Time {\n dob := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)\n return dob\n}<\/code><\/pre>\n\n\n\n
2011-04-02\nApril 02, 2011<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"