Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 35 of 60 · Go

Time Package – Parsing, Formatting, and Timers

Duration: 15 minutes

Working with Time

This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.

now := time.Now()
fmt.Println(now.Format(time.RFC3339))

// Parse ISO‑8601
t, err := time.Parse(time.RFC3339, "2024-03-25T12:34:56Z")

// Timer & After
timer := time.NewTimer(2 * time.Second)
<-timer.C // blocks for 2 s

Tickers (periodic actions)

ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()
for range ticker.C {
    fmt.Println("tick")
}

Timezones

loc, _ := time.LoadLocation("America/New_York")
nyc := now.In(loc)

Info

Always use time.Now().UTC() when persisting timestamps to a database.

Previous: File System Operations with `os` and `io/ioutil`Next: Encoding & Decoding – JSON, XML, and Gob