Get week day in portuguese language from date in moment js

10,350

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.

Share:
10,350
Napster
Author by

Napster

I am a India based php developer with 3 years commercial experience in PHP/MySQL – (LAMP/WAMP) and PHP-Oracle. Strong knowledge of ADODB database layer. Knowledge of PHP frameworks - Zend, Codeigniter, Yii, Cake. I have very good commercial experience in analysis, design, development, testing and implementation of web applications. Selfmade and good communicator which help me to work with clients at all levels of the business. All my current work is developed using the latest version of PHP and MySQL and my code is upto the current standards and secure.

Updated on June 11, 2022

Comments

  • Napster
    Napster almost 2 years

    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 ?