0
Not a bug

Date issues - different between app and Salesforce

Foxy 2 years ago in Data Mobilsation • updated by Todd 2 years ago 3

There is an issue after we were able to sync successfully, the values getting stored in Salesforce DB are not the same as the mobile table for the dateTime fields


We seeing the below in the SFDC DB
Checked_In__c = 24/09/2016 20:00

but in the app we are seeing 25/09/2016 00:00


The latter is correct.

Answer

+1
Answer
Under review

Hey Foxy,


So a couple of things to note here;

  1. the default behaviour of Salesforce is to render datetimes in the user's localtime, and also that by default JavaScript will render and collect dates (though input type=date) in the local time of the user's environment too.
  2. The dates stored in the device's local SmartStore (inc Codeflow) and in the platform are in UTC/GMT

If you want to make sure you collect a date in UTC you can use and ng-option directive in the input, like this;


<input type="date"  ng-model="myDate__c"  ng-model-options="{ timezone: 'UTC' }"/>

It is quite likely that actually the date is OK, and it's the rendering of the values that is confusing. Could you confirm your local timezone setting in Salesforce, please?

+1
Answer
Under review

Hey Foxy,


So a couple of things to note here;

  1. the default behaviour of Salesforce is to render datetimes in the user's localtime, and also that by default JavaScript will render and collect dates (though input type=date) in the local time of the user's environment too.
  2. The dates stored in the device's local SmartStore (inc Codeflow) and in the platform are in UTC/GMT

If you want to make sure you collect a date in UTC you can use and ng-option directive in the input, like this;


<input type="date"  ng-model="myDate__c"  ng-model-options="{ timezone: 'UTC' }"/>

It is quite likely that actually the date is OK, and it's the rendering of the values that is confusing. Could you confirm your local timezone setting in Salesforce, please?

OK. I am EST. This is four hours out so makes sense. I hope I can find a way to show these dates correct without the need to switch timezone setting.