Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

golang time / date まわりのメモ

自分用メモ

iso-8601 形式の日時のパース

t, err := time.Parse(time.RFC3339Nano, "2013-06-05T14:10:43+09:00")
fmt.Println(t)
// => 2013-06-05 14:10:43 +0900 +0900

指定した日時の1日、前月の1日

now := time.Now()

// 当月1日
a := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())

// 前月1日
b := a.AddDate(0, -1, 0)

fmt.Println(a)
fmt.Println(b)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
1
Help us understand the problem. What are the problem?