I was unable to find the answer in the documentation, so...
Consider this scenario: I have an input date of "09/01/2017". It could be either DD/MM/YYYY or MM/DD/YYYY format based on user locale. Is there a way to achieve something like this?
let date = "09/01/2017",
locale = "en_US", // or "en_AU"
result = moment(date, locale).format("DD MMM YYYY");
// 01 Sep 2017
// 09 Jan 2017
Alternatively, should I create a map and then assign a format to moment?
let map =
{
en_US: 'DD/MM/YYYY',
en_AU: 'MM/DD/YYYY',
// ...
},
date = "09/01/2017",
locale = "en_US",// or "en_AU"
result = moment(date, map[locale]).format("DD MMM YYYY");
// 01 Sep 2017
// 09 Jan 2017
Thank you.