Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:26
Show Gist options
  • Select an option

  • Save dacr/b796b8bfd910d2fc523ade64d2c6b9db to your computer and use it in GitHub Desktop.

Select an option

Save dacr/b796b8bfd910d2fc523ade64d2c6b9db to your computer and use it in GitHub Desktop.
go date time operations / published by https://github.com/dacr/code-examples-manager #e2ce7224-64ea-44c0-9d24-b17bf6d493ef/cb479be2b15bed27440c266b688d00c956a24dd1
/*?sr/bin/true; exec /usr/bin/env nix-shell -p go --run "go run $0" #*/
// summary : go date time operations
// keywords : go, date, time, @testable
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// id : e2ce7224-64ea-44c0-9d24-b17bf6d493ef
// created-on : 2025-03-27T09:18:20+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : nix-shell -p go --run "go run $file"
package main
import (
"fmt"
"time"
)
func main() {
current := time.Now()
fmt.Println(current)
fmt.Println(current.Format("2006-01-02 15:04:05"))
fmt.Println(current.Format("2006-01-02T15:04:05.000Z07:00")) // ISO 8601
fmt.Println(current.Format(time.RFC3339))
fmt.Println(current.Format(time.RFC3339Nano))
fmt.Println(current.Format(time.ANSIC))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment