Как настроить глобальные параметры формата по умолчанию (например, при запуске приложения), чтобы я всегда видел двузначные числа для месяца и дня?
var date = new Date(Date.UTC(2012, 11, 1, 3, 0, 0));
// Results below assume UTC timezone - your results may vary
console.log(new Intl.DateTimeFormat('en-US', { year: 'numeric', month: '2-digit', day: '2-digit' }).format(date));
// expected output: "12/01/2012"
console.log(new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).format(date));
// expected output: "01/12/2012"
console.log(new Intl.DateTimeFormat('de-DE', { year: 'numeric', month: '2-digit', day: '2-digit' }).format(date));
// expected output: "01.12.2012"
Ниже приведено поведение по умолчанию, используемое API-интерфейсом INTL.(одна цифра)
var date = new Date(Date.UTC(2012, 11, 1, 3, 0, 0));
// Results below assume UTC timezone - your results may vary
console.log(new Intl.DateTimeFormat('en-US').format(date));
// expected output: "12/1/2012"
console.log(new Intl.DateTimeFormat('en-GB').format(date));
// expected output: "01/12/2012"
console.log(new Intl.DateTimeFormat('de-DE').format(date));
// expected output: "1.12.2012"