javascript 西班牙语中的 MomentJS 时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30842477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MomentJS time in spanish
提问by Alpha2k
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:
我正在使用下一个代码来转换从 MySQL 数据库格式接收的日期1993-10-23 00:00:00
并以西班牙语显示:
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:
10月23日是星期六。我希望得到,sábado
但我得到了下一个:
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.
也尝试添加:moment.locale('es-ES');
,moment.locale('en-ES');
和moment.locale('es');
但既不工程。
What's the correct way of converting dates from a language to another?
将日期从一种语言转换为另一种语言的正确方法是什么?
回答by Alpha2k
This seems to work, thanks @RobG
这似乎有效,谢谢@RobG
var localLocale = moment('1993-10-23 00:00:00');
moment.locale('es');
localLocale.locale(false);
alert(localLocale.format('LLLL'));
回答by Guillermina Galache
The following method worked for me
以下方法对我有用
moment(agreement.dateStart).locale('es').format('LLLL')