本稿では、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オブジェクトが返った。
Go to list of users who liked
More than 5 years have passed since last update.
本稿では、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オブジェクトが返った。
Register as a new user and use Qiita more conveniently
Go to list of users who liked