Help us understand the problem. What is going on with this article?

golang time / date まわりのメモ

More than 1 year has passed since last update.

自分用メモ

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

https://play.golang.org/p/ttaY9IRr0lI

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)
mercari
フリマアプリ「メルカリ」を、グローバルで開発しています。
https://tech.mercari.com/
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