LoginSignup
0
0

More than 1 year has passed since last update.

node + javascript で今日の日付を文字列に変換する、YMD形式で出力する例 #javascript #node

Last updated at Posted at 2020-02-23

なにやら strftime 的な YMD 形式でうまく区切るメソッドはなさそう?

node


> new Date().toISOString().split('T')[0]
'2020-02-22'

> new Date().toDateString()
'Sat Feb 22 2020'

> new Date().toDateString()
'Sat Feb 22 2020'

> new Date().toGMTString()
'Sat, 22 Feb 2020 08:43:15 GMT'

> new Date().toISOString()
'2020-02-22T08:43:22.536Z'

> new Date().toJSON()
'2020-02-22T08:43:31.867Z'

> new Date().toLocaleDateString()
'2/22/2020'

> new Date().toLocaleTimeString()
'5:43:53 PM'

> new Date().toLocaleString()
'2/22/2020, 5:44:00 PM'

> new Date().toString()
'Sat Feb 22 2020 17:44:09 GMT+0900 (Japan Standard Time)'

> new Date().toTimeString()
'17:44:15 GMT+0900 (Japan Standard Time)'

> new Date().toUTCString()
'Sat, 22 Feb 2020 08:44:22 GMT'

こんな prototype の関数が見つかるが、採用されなかったのだろうか

Date.prototype.toLocaleFormat() - JavaScript | MDN

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
1

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