Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

moment.js year/number format with arabic locale

I am formatting dates using moment.js with arabic locale (ar_SA) set.

moment.locale('ar_SA');
moment([2016,05,01]).format('MMM YYYY');
//output مايو ٢٠١٦

I would like to format only the month part using the locale, but the year in english, example: "مايو 2016" (the same as when formatting using the angular filter: | date:'MMM yyyy')

Is there a way to configure moment.js to do this automatically? (instead of splitting the month and year formatting and simply concatenating 2016 to .format('MMM'))

like image 212
netsurferj Avatar asked May 05 '16 07:05

netsurferj


1 Answers

moment.updateLocale('en', {
    months : [
        "January", "February", "March", "April", "May", "June", "July",
        "August", "September", "October", "November", "December"
    ]
});

Source: https://momentjs.com/docs/#/customization/month-names/

like image 200
Roberto Aguilar Avatar answered Sep 21 '22 05:09

Roberto Aguilar