Shruti Desai
Posts: 0
Joined: Wed Apr 15, 2015 2:57 pm

moment.js doesn't work on ios

I'm using moment.js to format a date I get from the db service.

It works fine if I test the app in the browser but doesn't work if I test my app on the phone.

var availableAtDate = moment(new Date(newData.availableAt)).calendar();

Any thoughts?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

moment.js doesn't work on ios

Hi Shruti,

Please following JS code. Also you can check what actually you have in your availableAt data.

pre

var stringDate = newData.availableAt;

console.log("availableAt = " + stringDate);
console.log(new Date(stringDate));

var arrDate = stringDate.split(/[- :]/);
var date = new Date(arrDate[0], arrDate[1]-1, arrDate[2], arrDate[3], arrDate[4]);

var availableAtDate = moment(date).calendar();

/pre

Then open app with WEINRE debugger to see console.log from your ios device.

Regards.

Return to “Issues”