Skip to content

Instantly share code, notes, and snippets.

@tomowarkar
Last active December 11, 2019 08:42
Show Gist options
  • Save tomowarkar/f553f2e9fe10ba67a524cdb041ee5d6f to your computer and use it in GitHub Desktop.
Save tomowarkar/f553f2e9fe10ba67a524cdb041ee5d6f to your computer and use it in GitHub Desktop.
Goでのタイムスタンプ
package main
import (
"fmt"
"time"
)
func main() {
t := time.Now()
timestamp := fmt.Sprintf("%04d%02d%02d%02d%02d%02d",
t.Year(), t.Month(), t.Day(),
t.Hour(), t.Minute(), t.Second(),
)
fmt.Println(timestamp) // yyyyMMddHHmmss
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment