3 ms·
That's what Intl.DateTimeFormat is for. var options = { year: 'numeric', month: '2-digit', day: '2-digit'}; console.log(new Intl.DateTimeFormat('te-IN'
by bufferoverflow 6y ago
That's what Intl.DateTimeFormat is for.
var options = { year: 'numeric', month: '2-digit', day: '2-digit'};
console.log(new Intl.DateTimeFormat('te-IN', options).format(new Date()));
// outputs 16-09-2020
- mcv 6y agoNot as far as I can tell. It just formats it according to a locale, not according to a format string. SimpleDateFormat for javascript[0] looks more like what I need. Locales are exactly the thing I don't need. [0] https://github.com/noahcooper/SimpleDateFormatJS https://github.com/noahcooper/SimpleDateFormatJS
- bufferoverflow 6y agoWhy use a whole freaking library instead of just writing a one-line function?
- mcv 6y agoBecause I'd have to write a lot of variations of that one-line function to handle different date format variations from various systems.