13
4

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.

TypeScript: date-fnsでyyyy-MM-ddをパースする

Posted at

本稿では、TypeScriptで日付ライブラリdate-fnsを用い、年月日の文字列をパースする方法を紹介する。

import { parse } from 'date-fns'

console.log(parse('2019-08-01', 'yyyy-MM-dd', new Date()))

実行結果:

2019-07-31T15:00:00.000Z

タイムゾーンが+09:00なので、前日の15時のDateオブジェクトが返った。

参考

13
4
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
13
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?