0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Go言語で日付を表す文字列をパースしてtime.Time を利用したときの覚書

Posted at

Go 言語で日付を表す文字列をパースした。
Outlook の msg から日付情報を取得したら "Mon, 24 Jun 2019 20:36:40 +0900"のようなフォーマットだった。
この文字列を time.Time 型への変換以下で可能

	str := "Mon, 24 Jun 2019 20:36:40 +0900"
	layout := "Mon, 2 Jan 2006 15:04:05 -0700"
	t, _ := time.Parse(layout, str)
	fmt.Println(t) // => "2001-05-24 22:56:30 +0900 JST"

参考

Goのtimeパッケージのリファレンスタイム(2006年1月2日)は何の日?
逆引きGolang (日付と時刻)

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?