Ionic 2 Calendar date argument type not assignable for createEvent()

I am trying to create calendar event using my app. Basically, on button click, it should add an event to mobile calendar. I am receiving an error : Argument of type ‘“2017-04-25”’ is not assignable to parameter of type ‘Date’.

Below is my code:

this.calendar.createEvent(‘Space Race’, ‘The Moon’, ‘Bring sandwiches’,‘2017-04-25’, ‘2017-04-25’)
.then(() => {

The error seems pretty self-explanatory: it wants a Date and you gave it a string.

new Date(2017, 4, 25);

Note: don’t give the Date constructor a string. JavaScript’s string date parsing is notoriously unreliable.

1 Like

Thanks. Totally missed that.