Format date according to language, place and specify its style of writing in javascript.๐
Formatieren Sie das Datum nach Sprache, Ort und Schreibweise in Javascript.๐
const date = new Date();
const options = {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric"
};
console.log(date.toLocaleDateString("en-US", options));
//Sunday, January 26, 2020
console.log(date.toLocaleDateString("ar-EG", options));
//ุงูุฃุญุฏุ ูขูฆ ููุงูุฑ ูขู ูขู
console.log(date.toLocaleDateString("ar-SA", options));
//ุงูุฃุญุฏุ ูก ุฌู
ุงุฏู ุงูุขุฎุฑุฉ ูกูคูคูก ูู
console.log(date.toLocaleDateString("de-DE", options));
//Sonntag, 26. Januar 2020
Top comments (1)
I would recommend taking a look at the Intl object in JS. There are tons of capabilities built into it, which I see folks rewrite all the time.