从js的日期开始用葡萄牙语获取工作日

时间:2015-01-23 12:46:19

标签: angularjs momentjs angular-moment

这是我的代码

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

它以英文返回工作日名称,但需要葡萄牙语工作日名称

如果我通过 1_1_2015 ,则返回星期四

如何以葡萄牙语获得工作日名称?

修改

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"]

我已经包含 moment-with-locales.min.js 文件,其中包含所有受支持的语言数据,并且它可以与上层代码配合使用。那为什么它不适用于周名?

1 个答案:

答案 0 :(得分:5)

试试这个(source):

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

the GitHub page上记录问题可能是值得的,我认为您的代码应该有用,或者应该改进文档。