On a modern browser you can use the Intl API
The Intl object is the namespace for the ECMAScript
Internationalization API, which provides language sensitive string
comparison, number formatting, and date and time formatting. The
constructors for Collator, NumberFormat, and DateTimeFormat objects
are properties of the Intl object.
Parsing is performed manually, Date.parse
It is not recommended to use Date.parse as until ES5, parsing of
strings was entirely implementation dependent. There are still many
differences in how different hosts parse date strings, therefore date
strings should be manually parsed (a library can help if many
different formats are to be accommodated).
Date.UTC is used to provide a date from parts
for Intl.DateTimeFormat#format.
The Date.UTC() method accepts the same parameters as the longest form
of the constructor, and returns the number of milliseconds in a Date
object since January 1, 1970, 00:00:00, universal time
Finally the ,
's are removed from the en-US
formatted string so that it matches your requirement.
const parts = '02/12/2013'.split('/');
parts.unshift(parts.pop());
parts[1] -= 1;
const dateString = new Intl.DateTimeFormat('en-US', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
timeZone: 'UTC'
}).format(Date.UTC(...parts)).replace(/,/g, '');
console.log(dateString);
moment.js
or want only pure javascript? – Stichomythiasomething like
oraccurately
? – Basilicata