Try to use ar-eg
instead of just ar
:
console.log(date.toLocaleDateString("ar-eg", dateOptions));
But remember that the toLocaleDateString
implentation is always application dependent, furthermore there are browsers that do not implement the locale
/option
parameters.
You can check the language and options support by using the following functions:
function dateSupportsLocales(language) {
try {
new Date().toLocaleDateString(language);
} catch (e) {
return e.name !== 'RangeError';
}
return true;
}
function dateSupportsOptions() {
try {
new Date().toLocaleDateString('en', {});
return true;
}
catch (e) { }
return false;
}
Check also the Date.prototype.toLocaleDateString
MDN Reference for more informations.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…