javascript - moment.js: format a date keeping the locale's day, month and year order -
i using moment.js format dates in "country specific" order, using native locale feature. so, example, code print date ordered in netherlands's default:
moment.locale('nl'); nldate = moment(); nldate.format('ll'); // "12 nov. 2014"
a different locale setting print different order:
moment.locale('en'); nldate = moment(); nldate.format('ll'); // "nov 12, 2014"
what change format of output string, keeping locale order; example:
(nl) 12 nov. 2014 --> 12-11-'14 (en) nov 12, 2014 --> 11-12-'14
sadly, custom format, not able keep locale order:
nldate = moment(); nldate.locale('nl'); nldate.format("dd-mm-'yy"); // "12-11-'14" nldate.locale('en'); nldate.format("dd-mm-'yy"); // "12-11-'14"
from above get:
(nl) 11-12-'14 (en) 12-11-'14
any help?
i addressing effort here , here not sure in right direction.
thank you, luca
try this,
moment.locale("nl").format('l');
and
moment.locale("en").format('l');
Comments
Post a Comment