简体   繁体   English

如何用moment.js解析日期?

[英]How to parse a date with momentjs?

I'm trying to parse a date in momentjs , in particular this is my goal: 我正在尝试解析一下momentjs的日期,尤其是我的目标:

Ven Nov 13 2015 09:00:00 Ven十一月13 2015 09:00:00

Now I'm using FullCalendar and when I get the .start date it's returned this: 现在,我使用FullCalendar,当我得到的.start日期它返回此:

Fri Nov 13 2015 00:00:00 2015年11月13日星期五00:00:00

how you can see in my bottom code, I'm format the calendarDateStartTemp to utc for remove the GMT. 您如何在我的底部代码中看到,我将calendarDateStartTemp格式化为utc以删除GMT。 In the next step, I transform the object in italian timezone, but this seems not working. 下一步,我将对象转换为italian时区,但这似乎不起作用。 Anyway, I've in workingPlan[selDayName].start the hour to edit, in particular this is the value: 09:00:00 , see the code: 不管怎么说,我在workingPlan[selDayName].start的小时进行编辑,尤其是这条价值: 09:00:00 ,看到代码:

var calendarDateStartTemp = $calendar.fullCalendar('getView').start;
                        var calendarDateStart = moment(calendarDateStartTemp).utc().format("ddd MMM DD YYYY HH:mm:ss");

var calendarDateEnd = moment.lang('it');

calendarDateEnd = moment(moment(calendarDateStart).format("YYYY-MM-DD") + ' '
                                    + workingPlan[selDayName].start).format('ddd, D MMM YYYY HH:mm:ss');

now the problem's that I get this result: 现在的问题是我得到了这个结果:

Fri, 13 Nov 2015 09:00:00 2015年11月13日星期五09:00:00

instead of this: 代替这个:

Ven Nov 13 2015 09:00:00 Ven十一月13 2015 09:00:00

how you can see the date returned is in english language, but I don't know why moment.lang now working. 如何查看返回的日期是英语,但我不知道为什么moment.lang现在可以正常工作。 I say that it's deprecated so I've also tried with moment.locale but I've the same problem. 我说它已被弃用,所以我也尝试过使用moment.locale但我遇到了同样的问题。 How I can fix this? 我该如何解决?

NB: the language is italian 注意:语言是意大利语

var data = moment().locale('it').format('llll');
alert(data);

By default, Moment.js comes with English locale strings. 默认情况下,Moment.js随附英语语言环境字符串。 If you need other locales, you can load them into Moment.js. 如果需要其他语言环境,可以将它们加载到Moment.js中。

I'm assuming you have both moment.js and monement+locales.js included, the scripts are found here. 我假设您同时包含了moment.js和monement + locales.js,可以在此处找到脚本。 http://momentjs.com/ http://momentjs.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM