loading...

How to Format Date in Javascript

twitter logo github logo ・1 min read

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
twitter logo DISCUSS (1)
markdown guide
 

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.

Classic DEV Post from Aug 27 '19

How do *you* pronounce sudo?

Islam Sayed profile image
A Freelance Front-End Web Developer, tech writer, and mentor at Udacity.

Signed up yet?

DEV is where coding careers are built.

Create Your Account