Ionic Local Notifications GetAll At field date value

Hi,

I am using the local notifications plugin on my app.

It works pretty fine when it comes to setting the notifications.

But I am a little confused with the way the returned at field works.

When I schedule the notification I used the momentjs plugin and did the following for the at parameter of the schedule call

this.localNotifications.schedule({
   "id": 1,
    "text": "test notification",
     "at": moment("05 Sep 2017").toDate()
})

Now if I use the getAll method to get the notifications then the value that is set for the “at” parameter is

“at”: 1504602000

When I pipe it through moment, this is the date value that I get.

1970-01-18T09:56:42.000Z

This is pretty much the case for every other date value that I set using the both moment and default Date type of javascript. I am not sure where the issue is.

My guess is the returned value in “at” is a date format that I don’t understand. Can some one please explain the format of the date value returned by the “at” field in the getAll() method.

Cheers,

SD

I would guess seconds since the epoch, so you can just multiply that by 1000 to get something you can pass to the Date constructor. BTW, take a look at date-fns as a replacement for moment. It is much lighter and amenable to dead code elimination, and works with both ISO8601 strings and Date objects, so there is no need to create unwanted moment objects.

Hey @rapropos

Thanks a ton. You were spot on mate.

Now this ends a 2 week puzzle of breaking my head.

I just multiplied by 1000 and passed it into the moment and got 5 Sep as expected.

I will definitely try the date-fns plugin.

Cheers mate,

SD