JavaScript で Date 型を String に変える際に format を指定できる。
let today = new Date()
today.toLocaleString(locales, options)
locales
地域に基づく表示形式になる
- ‘de-DE’
- ‘ja-JP’
- ‘en-IN’ など
options
連想配列で指定
{
hour12:[true,false],
era:["narrow","short","long"],
year:["numeric","2-digit"],
month:["numeric","2-digit","narrow","short","long"],
day:["numeric","2-digit"],
weekday:["narrow","short","long"],
hour:["numeric","2-digit"],
minute:["numeric","2-digit"],
second:["numeric","2-digit"],
timeZoneName:["short","long"]
timeZone:["foo/bar"]
}
timeZone は日本なら”Asia/Tokyo”という表記方法。 一覧が Wikipedia に載っている。
List of tz database time zones | Wikipedia