根据MDN 文档,Date.toLocaleString()第二个参数是一个options参数:
toLocaleString(locales, options)
Run Code Online (Sandbox Code Playgroud)
他们在示例中使用:
let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
// Request a weekday along with a long date
let options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
console.log(date.toLocaleString('de-DE', options));Run Code Online (Sandbox Code Playgroud)
我的问题是,参数可能有哪些属性options?
Spe*_*ric 17
Intl.DateTimeFormat()它与构造函数的相同,其MDN 文档提供了每个有效属性的列表和解释。
可能的属性如下:
dateStyletimeStylecalendardayPeriodnumberingSystemlocaleMatchertimeZonehour12hourCycleformatMatcherweekdayerayearmonthdayhourminutesecondfractionalSecondDigitstimeZoneName有关每个属性和行为的可能值,请参阅MDN 文档。