WTF!? appSettings.getNumber returns different value then set by setNumber


I have a Date object that I save via appSettings, specifically,

appSettings.setNumber(, dbDate.getTime());

But, when I retrieve the value, it’s different. Here’s the code snippet:

console.log("dbDate: " +  dbDate.toISOString() + ", " + dbDate.getTime());
              appSettings.setNumber(, dbDate.getTime()); 
              console.log("appSettings date: " + new Date(appSettings.getNumber(, 0)).toISOString() + ", " + new Date(appSettings.getNumber(, 0)).getTime());

And here’s the console output:

JS: dbDate: 2018-07-03T20:14:44.000Z, 1530648884000
JS: appSettings date: 2018-07-03T20:14:14.528Z, 1530648854528

One might reasonably expect the two values to be identical. Is there a precision limitation with appSettings?


I’m not sure but it looks like a time zone issue. What is the source for dbDate, how you are creating that.


@manojdcoder - dbDate is set from a Last-Modified header, namely,

var dbDate = new Date(response.headers["Last-Modified"]); 

But that almost doesn’t matter, because you can see the GetTime() value that’s saved (just a large integer) is not the same value that’s retrieved. The two seem to differ by 4-13 seconds, but only on Android (both emulator and real device). On iOS they are identical.

I’m working around this by assuming that a newer database will be at least 30 seconds older, but still, this seems like a basic data integrity problem. I’d make a playground to demonstrate but I’d need the AppSettings plugin, and playgrounds don’t yet allow plugins, yes?


If you look at your logs, dbDate is in UTC and appSettings is in different timezone (may be it’s your local machine’s). So I believe they are equal but in different time zones, you might have to take a closer look there.


I was able to create a playground, see

This is a bona-fide problem, and I will open an issue. The set/get work correctly on iOS, but are always different on Android.