Go Packages
pkg.go.dev › time
time package - time - Go Packages
Package time provides functionality for measuring and displaying time.
Go by Example
gobyexample.com › time
Go by Example: Time
Go offers extensive support for times and durations; here are some examples · We’ll start by getting the current time
Videos
Working with Time in Go - Practical Guide
07:37
Working with Time in Go - YouTube
03:43
Golang standard library - Time Package part 11 - YouTube
01:25
How to Convert a String to a Time in Golang - YouTube
11:44
Handling time in golang - YouTube
17:09
☀️🌴 The Ultimate Go Tour #2 ❤️ Understanding Time - ...
DigitalOcean
digitalocean.com › community › tutorials › how-to-use-dates-and-times-in-go
How To Use Dates and Times in Go | DigitalOcean
February 2, 2022 - Date and time values show up everywhere in modern software. Learn to use Go’s time package to get the current local time of your computer and customize the f…
Go
go.dev › src › time › time.go
time.go
89 // On older Windows versions, ... 93 import ( 94 "errors" 95 "math/bits" 96 _ "unsafe" // for go:linkname 97 ) 98 99 // A Time represents an instant in time with nanosecond precision....
UBC Computer Science
cs.ubc.ca › ~bestchai › teaching › cs416_2015w2 › go1.4.3-docs › pkg › time › index.html
time - The Go Programming Language
Package time provides functionality for measuring and displaying time · The calendrical calculations always assume a Gregorian calendar
Go
go.dev › src › time › format.go
Time.Format
193 // 194 // nextStdChunk should be an internal detail, 195 // but widely used packages access it using linkname. 196 // Notable members of the hall of shame include: 197 // - github.com/searKing/golang/go 198 // 199 // Do not remove or change the type signature.
Top answer 1 of 9
190
Use the time.Now() function and the time.Format() method.
t := time.Now()
fmt.Println(t.Format("20060102150405"))
prints out 20110504111515, or at least it did a few minutes ago. (I'm on Eastern Daylight Time.) There are several pre-defined time formats in the constants defined in the time package.
You can use time.Now().UTC() if you'd rather have UTC than your local time zone.
2 of 9
88
All the other response are very miss-leading for somebody coming from google and looking for "timestamp in go"! YYYYMMDDhhmmss is not a "timestamp".
To get the "timestamp" of a date in go (number of seconds from january 1970), the correct function is Time.Unix(), and it really return an integer
Go
go.dev › src › runtime › time.go
Time-related runtime and pieces of package time.
6 7 package runtime 8 9 import ( 10 "internal/abi" 11 "internal/runtime/atomic" 12 "internal/runtime/sys" 13 "unsafe" 14 ) 15 16 //go:linkname time_runtimeNow time.runtimeNow 17 func time_runtimeNow() (sec int64, nsec int32, mono int64) { 18 if bubble := getg().bubble; bubble != nil { 19 sec = bubble.now / (1000 * 1000 * 1000) 20 nsec = int32(bubble.now % (1000 * 1000 * 1000)) 21 // Don't return a monotonic time inside a synctest bubble.
Go
go.dev › src › time › example_test.go
round := []time.Duration
2*time.Minute + 300*time.Millisecond) 55 fmt.Println(300 * time.Millisecond) 56 // Output: 57 // 1h2m0.3s 58 // 300ms 59 } 60 61 func ExampleDuration_Truncate() { 62 d, err := time.ParseDuration("1h15m30.918273645s") 63 if err != nil { 64 panic(err) 65 } 66 67 trunc := []time.Duration{ 68 time.Nanosecond, 69 time.Microsecond, 70 time.Millisecond, 71 time.Second, 72 2 * time.Second, 73 time.Minute, 74 10 * time.Minute, 75 time.Hour, 76 } 77 78 for _, t := range trunc { 79 fmt.Printf("d.Truncate(%6s) = %s\n", t, d.Truncate(t).String()) 80 } 81 // Output: 82 // d.Truncate( 1ns) = 1h15m30.91827364
Reddit
reddit.com › r/golang › the docs for go's time package jump straight into the deep end. i wrote this article as a (hopefully!) more approachable intro to time and location.
r/golang on Reddit: The docs for Go's time package jump straight into the deep end. I wrote this article as a (hopefully!) more approachable intro to Time and Location.
December 21, 2023 - What happened to Go Time podcast? r/golang • · upvotes · · comments · How to format time in Go/Golang? r/golang • · upvotes · · comments · Timekit – Helpful functions to extend the Go `time` standard package · r/golang • · upvotes · · comments · Get current time from monotonic clock source ·
ZetCode
zetcode.com › golang › datetime
Working with Date and Time in Go
May 4, 2025 - Learn how to work with date and time in Go. Includes examples of parsing and formatting.
YourBasic
yourbasic.org › golang › format-parse-string-time-date-example
Format a time or date [complete guide] · YourBasic Go
ANSIC = "Mon Jan _2 15:04:05 2006" UnixDate = "Mon Jan _2 15:04:05 MST 2006" RubyDate = "Mon Jan 02 15:04:05 -0700 2006" RFC822 = "02 Jan 06 15:04 MST" RFC822Z = "02 Jan 06 15:04 -0700" RFC850 = "Monday, 02-Jan-06 15:04:05 MST" RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST" RFC1123Z = "Mon, 02 Jan 2006 15:04:05 -0700" RFC3339 = "2006-01-02T15:04:05Z07:00" RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00" Kitchen = "3:04PM" // Handy time stamps.