Created
March 28, 2025 09:01
-
-
Save dacr/9dcfa080fd9b6e7363a76dccfeb6bf76 to your computer and use it in GitHub Desktop.
go date types / published by https://github.com/dacr/code-examples-manager #841161a1-9f6f-4301-818b-4a576edbd190/822c568d00ce77c427e81f83357cadb00f2fea53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*?sr/bin/true; exec /usr/bin/env nix-shell -p go --run "go run $0" #*/ | |
// summary : go date types | |
// keywords : go, date-types, @testable | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : 841161a1-9f6f-4301-818b-4a576edbd190 | |
// 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