简体   繁体   中英

How to parse a date with momentjs?

I'm trying to parse a date in momentjs , in particular this is my goal:

Ven Nov 13 2015 09:00:00

Now I'm using FullCalendar and when I get the .start date it's returned this:

Fri Nov 13 2015 00:00:00

how you can see in my bottom code, I'm format the calendarDateStartTemp to utc for remove the GMT. In the next step, I transform the object in italian timezone, but this seems not working. Anyway, I've in workingPlan[selDayName].start the hour to edit, in particular this is the value: 09:00:00 , see the code:

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

instead of this:

Ven Nov 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. I say that it's deprecated so I've also tried with moment.locale but I've the same problem. 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. If you need other locales, you can load them into Moment.js.

I'm assuming you have both moment.js and monement+locales.js included, the scripts are found here. http://momentjs.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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