Set a locale in javascript

You should use moment.js to parse dates.

//parse string according to format and return new moment
var day = moment("16/12/2017", "DD/MM/YYYY");  

var dayAsDate = day.toDate();  //you can even covert the moment to a Date

Globalize also has a date parsing module if you need to handle date strings in other locales/scripts.


You can now use JavaScript's Internationalization API because it's now supported in all browsers. It allows you to pass in a locale, which will customize the date format.

console.log(new Intl.DateTimeFormat('en-GB').format(date));

Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat