0
0

More than 1 year has passed since last update.

【Golang】日付の月を数値で取得する

Posted at

結論

main.go
package main

import (
	"fmt"
	"time"
)

func main() {

    // Januaryなどの英語表記で取得
    targetMonthString := time.Now().Month()
    fmt.Println("targetMonthString: ",targetMonthString)

    // 1や2などの数値で取得
    targetMonthInt := int(time.Now().Month())
    fmt.Println("targetMonthInt: ",targetMonthInt)
}
~/go/src/jikken$ go run main.go
targetMonthString:  January
targetMonthInt:  1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0