5

This is my code

$scope.getWeekDayShort = function(date) {
                moment().locale('pt-br');
                return moment(date, "D_M_YYYY").format('ddd');
            }

it returns name of weekday in english but need portuguese weekday name

If I pass 1_1_2015 it returns Thu

How can I get weekday name in portuguese?

EDIT

moment.locale('pt-br');
console.log(JSON.stringify(moment.months())) // ["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]
moment.locale('en');
console.log(JSON.stringify(moment.months())); // ["January","February","March","April","May","June","July","August","September","October","November","December"]

I have included moment-with-locales.min.js file which includes all supported language data and it work good with upper code. So why it not works with week name ?

Nisarg
  • 3,024
  • 5
  • 32
  • 54
  • Have you loaded a locale for this? [By default, Moment.js comes with English locale strings. If you need other locales, you can load them into Moment.js for later use.](http://momentjs.com/docs/#/i18n/) Make sure that you use [moment+locales.js](http://momentjs.com/downloads/moment-with-locales.js) – user247702 Jan 23 '15 at 12:49

1 Answers1

9

Try this (source):

moment(date, "D_M_YYYY").locale('pt-br').format('ddd')

Might be worth it to log an issue on the GitHub page, I think your code should work or the docs should be improved.

Community
  • 1
  • 1
user247702
  • 23,641
  • 15
  • 110
  • 157