Page 1 of 1

moment.js doesn't work on ios

Posted: Sat May 02, 2015 5:16 pm
by Shruti Desai

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?


moment.js doesn't work on ios

Posted: Mon May 04, 2015 12:59 am
by Yurii Orishchuk

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.