{"id":288,"date":"2026-04-27T09:00:00","date_gmt":"2026-04-27T03:30:00","guid":{"rendered":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/"},"modified":"2026-10-10T21:20:57","modified_gmt":"2026-10-10T15:50:57","slug":"go-time-package-examples","status":"publish","type":"post","link":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/","title":{"rendered":"Go Time Package: Dates, Durations and Timers"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The Go time package handles dates, clocks, durations and timers in one place. In this post, you will create dates and format them with Go&#8217;s unusual layout. Then you will do date maths and work with time zones. Each idea comes with a short example that you can run yourself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You already used <code>time.Sleep<\/code> and <code>time.After<\/code> in <a href=\"https:\/\/smitabharat.com\/blog\/go-select-statement\/\">the Go select statement<\/a>. Durations also appeared in <a href=\"https:\/\/smitabharat.com\/blog\/go-context-beginners-guide\/\">Go context for beginners<\/a>, so now let us look at time properly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Is the Go Time Package?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>time<\/code> package gives you two main types. A <code>time.Time<\/code> is a moment, such as 19 August 2026 at 9:30. A <code>time.Duration<\/code> is a length of time, such as 90 minutes. Most work mixes the two, for example &#8220;now plus 30 days&#8221;.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>t := time.Date(2026, time.August, 19, 9, 30, 0, 0, time.UTC)\nfmt.Println(t)                                       \/\/ 2026-08-19 09:30:00 +0000 UTC\nfmt.Println(t.Year(), t.Month(), t.Day(), t.Weekday()) \/\/ 2026 August 19 Wednesday<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Call <code>time.Now()<\/code> to get the current moment. However, examples here use a fixed date, so your output matches.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Formatting Dates with the Reference Layout<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most languages use codes like <code>YYYY-MM-DD<\/code>. Go instead uses one special reference date: Monday, 2 January 2006 at 15:04:05. You write that exact date in the shape you want, and Go copies the shape. The diagram below shows how each part maps.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-diagram-1024x640.png\" alt=\"Go Time Package diagram showing the reference time 2006-01-02 15:04:05 and how each part maps to a date\" class=\"wp-image-267\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-diagram-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-diagram-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-diagram-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-diagram-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-diagram-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Each part of the reference time stands for one piece of the output: 2006 is the year, 01 the month, 02 the day and 15:04 the time.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fmt.Println(t.Format(\"2006-01-02\"))            \/\/ 2026-08-19\nfmt.Println(t.Format(\"02 Jan 2006, 3:04 PM\"))  \/\/ 19 Aug 2026, 9:30 AM\nfmt.Println(t.Format(time.RFC3339))            \/\/ 2026-08-19T09:30:00Z\nfmt.Println(t.Format(\"YYYY-MM-DD\"))            \/\/ YYYY-MM-DD<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The last line is a classic trap. Go does not know <code>YYYY<\/code>, so it prints the letters unchanged. Here is a handy memory trick. The parts count up: month 01, day 02, hour 03 (15), minute 04, second 05 and year 06.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parsing Text into Dates<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>p, err := time.Parse(\"2006-01-02 15:04\", \"2026-08-25 18:45\")\nfmt.Println(p, err) \/\/ 2026-08-25 18:45:00 +0000 UTC &lt;nil&gt;\n\n_, err = time.Parse(\"2006-01-02\", \"25-08-2026\")\nfmt.Println(err)\n\/\/ parsing time \"25-08-2026\" as \"2006-01-02\": cannot parse \"25-08-2026\" as \"2006\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>time.Parse<\/code> uses the same layout idea in reverse, which keeps the Go time package consistent. So the layout must match the input shape exactly. Also, always check the error, because user input is often in the wrong format.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Durations and Date Maths in the Go Time Package<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>d := 90 * time.Minute\nfmt.Println(d, d.Hours()) \/\/ 1h30m0s 1.5\n\nlater := t.Add(36 * time.Hour)\nfmt.Println(later.Format(\"Mon 02 Jan 15:04\")) \/\/ Thu 20 Aug 21:30\nfmt.Println(later.Sub(t))                     \/\/ 36h0m0s\nfmt.Println(t.AddDate(0, 1, 0).Format(\"2006-01-02\")) \/\/ 2026-09-19\nfmt.Println(later.After(t))                   \/\/ true<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>Add<\/code> moves a moment by a duration, and <code>Sub<\/code> gives the gap between two moments. For calendar steps like &#8220;one month later&#8221;, use <code>AddDate<\/code> instead. In addition, compare moments with <code>Before<\/code>, <code>After<\/code> and <code>Equal<\/code> rather than <code>==<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Measuring How Long Code Takes<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>start := time.Now()\ndoWork()\nfmt.Println(\"took\", time.Since(start))<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>time.Since(start)<\/code> is a short way to write <code>time.Now().Sub(start)<\/code>. For example, it is perfect for logging slow requests.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Time Zones with the Go Time Package<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>loc, err := time.LoadLocation(\"Asia\/Kolkata\")\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Println(t.In(loc).Format(\"2006-01-02 15:04 MST\")) \/\/ 2026-08-19 15:00 IST<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With the Go time package, store times in UTC. Then convert to a local zone only when you show them to a person. This simple rule prevents most time zone bugs. On machines without zone data, such as tiny containers, add <code>import _ \"time\/tzdata\"<\/code> to embed it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Timers and Tickers<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>timer := time.NewTimer(20 * time.Millisecond)\n&lt;-timer.C\nfmt.Println(\"timer fired\")\n\nticker := time.NewTicker(time.Second)\ndefer ticker.Stop()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A timer fires once, while a ticker fires again and again. So always call <code>Stop<\/code> on a ticker when you finish, or it keeps running in the background.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with the Go Time Package<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem you see<\/th><th>Why it happens<\/th><th>How to fix it<\/th><\/tr><\/thead><tbody><tr><td>Output shows YYYY-MM-DD literally<\/td><td>Because go uses the 2006 layout, not letter codes.<\/td><td>So write the layout as &#8220;2006-01-02&#8221;.<\/td><\/tr><tr><td>cannot parse &#8220;25-08-2026&#8221; as &#8220;2006&#8221;<\/td><td>Because the layout does not match the input.<\/td><td>So make the layout follow the input shape.<\/td><\/tr><tr><td>unknown time zone Asia\/Kolkata<\/td><td>Because the machine has no zone database.<\/td><td>So import <code>time\/tzdata<\/code>.<\/td><\/tr><tr><td>Two equal times compare as different<\/td><td>Because <code>==<\/code> also compares the location.<\/td><td>So use <code>t1.Equal(t2)<\/code>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Date bugs are common in real projects and interviews alike. So practise with my <a href=\"https:\/\/smitabharat.com\/blog\/go-lang-interview-questions-and-answers\/\">Go interview questions and answers<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These pages come straight from the Go team, so they stay accurate and up to date.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pkg.go.dev\/time\">time package documentation<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pkg.go.dev\/time#pkg-constants\">time package: layout constants<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Go time package uses <code>time.Time<\/code> for moments and <code>time.Duration<\/code> for lengths.<\/li>\n\n\n\n<li>Format and parse with the reference time 2006-01-02 15:04:05.<\/li>\n\n\n\n<li>Use <code>Add<\/code>, <code>Sub<\/code>, <code>AddDate<\/code> and <code>time.Since<\/code> for date maths.<\/li>\n\n\n\n<li>Store in UTC and convert with <code>In<\/code> for display.<\/li>\n\n\n\n<li>Stop tickers when you no longer need them.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can now handle dates and durations. Next, we will search and transform text with regular expressions and the regexp package.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next lesson: <a href=\"https:\/\/smitabharat.com\/blog\/go-regular-expressions-regexp\/\">Go Regular Expressions with the regexp Package<\/a><\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>The Go time package handles dates, clocks, durations and timers in one place. In this post, you will create dates and format them with&hellip;<\/p>\n","protected":false},"author":1,"featured_media":266,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[15],"tags":[11,54,23,21],"swapz_series":[],"class_list":["post-288","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go-lang","tag-go-lang","tag-go-time","tag-go-tutorial","tag-golang-basics"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Go Time Package: Dates, Durations and Timers<\/title>\n<meta name=\"description\" content=\"Learn the Go time package with simple examples: format and parse dates with the 2006 layout, add durations, use time zones and timers.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go Time Package: Dates, Durations and Timers\" \/>\n<meta property=\"og:description\" content=\"Learn the Go time package with simple examples: format and parse dates with the 2006 layout, add durations, use time zones and timers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"Smita Bharat - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-27T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-10T15:50:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Smita\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Smita\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/\"},\"author\":{\"name\":\"Smita\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"headline\":\"Go Time Package: Dates, Durations and Timers\",\"datePublished\":\"2026-04-27T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:50:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/\"},\"wordCount\":625,\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-time-package-examples-featured.png\",\"keywords\":[\"Go Lang\",\"Go Time\",\"Go Tutorial\",\"Golang Basics\"],\"articleSection\":[\"Go Lang\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/\",\"name\":\"Go Time Package: Dates, Durations and Timers\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-time-package-examples-featured.png\",\"datePublished\":\"2026-04-27T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:50:57+00:00\",\"description\":\"Learn the Go time package with simple examples: format and parse dates with the 2006 layout, add durations, use time zones and timers.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/#primaryimage\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-time-package-examples-featured.png\",\"contentUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-time-package-examples-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Go Time Package featured image: cards for the 2006 layout, date maths and time zones\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-time-package-examples\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go Time Package: Dates, Durations and Timers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\",\"name\":\"Smita Bharat Blog\",\"description\":\"Golang &amp; Backend Development Tutorials and Interview Questions\",\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"alternateName\":\"Smita Bharat\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\",\"name\":\"Smita\",\"logo\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/smitabharat.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go Time Package: Dates, Durations and Timers","description":"Learn the Go time package with simple examples: format and parse dates with the 2006 layout, add durations, use time zones and timers.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/","og_locale":"en_US","og_type":"article","og_title":"Go Time Package: Dates, Durations and Timers","og_description":"Learn the Go time package with simple examples: format and parse dates with the 2006 layout, add durations, use time zones and timers.","og_url":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/","og_site_name":"Smita Bharat - Blog","article_published_time":"2026-04-27T03:30:00+00:00","article_modified_time":"2026-10-10T15:50:57+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-featured.png","type":"image\/png"}],"author":"Smita","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Smita","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/#article","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/"},"author":{"name":"Smita","@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"headline":"Go Time Package: Dates, Durations and Timers","datePublished":"2026-04-27T03:30:00+00:00","dateModified":"2026-10-10T15:50:57+00:00","mainEntityOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/"},"wordCount":625,"publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-featured.png","keywords":["Go Lang","Go Time","Go Tutorial","Golang Basics"],"articleSection":["Go Lang"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/","url":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/","name":"Go Time Package: Dates, Durations and Timers","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/#primaryimage"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-featured.png","datePublished":"2026-04-27T03:30:00+00:00","dateModified":"2026-10-10T15:50:57+00:00","description":"Learn the Go time package with simple examples: format and parse dates with the 2006 layout, add durations, use time zones and timers.","breadcrumb":{"@id":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smitabharat.com\/blog\/go-time-package-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/#primaryimage","url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-featured.png","contentUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-time-package-examples-featured.png","width":2400,"height":1260,"caption":"Go Time Package featured image: cards for the 2006 layout, date maths and time zones"},{"@type":"BreadcrumbList","@id":"https:\/\/smitabharat.com\/blog\/go-time-package-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smitabharat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go Time Package: Dates, Durations and Timers"}]},{"@type":"WebSite","@id":"https:\/\/smitabharat.com\/blog\/#website","url":"https:\/\/smitabharat.com\/blog\/","name":"Smita Bharat Blog","description":"Golang &amp; Backend Development Tutorials and Interview Questions","publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"alternateName":"Smita Bharat","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smitabharat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339","name":"Smita","logo":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/smitabharat.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/comments?post=288"}],"version-history":[{"count":2,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/288\/revisions"}],"predecessor-version":[{"id":313,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/288\/revisions\/313"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media\/266"}],"wp:attachment":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media?parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/categories?post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/tags?post=288"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}