MomentJS time in spanish

2019-02-07 05:01发布

I am using the next code to convert a date received from a MySQL database format 1993-10-23 00:00:00 and display it in spanish:

alert(moment('1993-10-23 00:00:00', 'YYYY-MM-DD', 'es')); 

23 oct is saturday. I would expect to get sábado but I get the next:

Sat Oct 23 1993 00:00:00 GMT+0200

Also tried adding: moment.locale('es-ES'); , moment.locale('en-ES'); and moment.locale('es'); but neither works.

What's the correct way of converting dates from a language to another?

1条回答
▲ chillily
2楼-- · 2019-02-07 05:34

This seems to work, thanks @RobG

var localLocale = moment('1993-10-23 00:00:00');
moment.locale('es');
localLocale.locale(false);
alert(localLocale.format('LLLL')); 
查看更多
登录 后发表回答