Skip to main content

I have a snippet which retrieves a DateTime field from multiple rows in a child model, converts each date to a string, and concatenates each date with a line break into a long text field on the parent model. (So that I can then send an html email template with this long text field included).

Snippet below:


var $ = skuid.$;<br> var parentEnquiry = skuid.model.getModel('CharterOpParent');<br>var parentRow = parentEnquiry.getFirstRow();<br>var Sectors = skuid.model.getModel('Sectors');<br>var descField = '';<br> $.each(Sectors.data, function (i, row){ &nbsp; &nbsp;//iterate over the rows<br>&nbsp; &nbsp; var jsDateTime = skuid.time.parseSFDate(row.stack__Date__c);<br>&nbsp; &nbsp; var jsDate = jsDateTime.toDateString();<br><br>&nbsp; &nbsp; descField += jsDate + '
';<br>&nbsp; &nbsp; console.log(jsDateTime);<br>&nbsp; &nbsp; console.log(jsDate);<br> });<br> console.log('************');<br>console.log(descField);<br> parentEnquiry.updateRow(parentRow,'stack__Special_Requirements__c',descField);



The issue with this is that it appears to be converting the time displayed in the browser into the current user’s locale. For example, if I enter two child rows with dates of:

26/11/2014 23:00
29/11/2014 00:00

Then the output the snippet populates into the long text field is:

Wed Nov 26 2014
Fri Nov 28 2014

7ed7b27564f0673713b2d218d4b4b753936e0581.jpg


Is there a different method to have this snippet retrieve the ‘actual’ time displayed on the users browser? (without any conversion for current user’s locale?)



 

Hi Greg,

Is there a particular timezone you would like to use?  For instance do you want to always use the timezone of your location?  Or something like GMT?  What is the timezone of the person doing the data entry of the datetimes in the first place?


Hi Ben,

Because we’re deploying in a managed package our users will potentially have many different time zones. What I’d really like to do is capture the time on the user’s browser.

Users refer to this as the ‘local time’ at point of departure for a trip (which is likely to be in a different time zone again from that of the user). So I really want to capture this ‘local time’ which is what the user sees in the browser. 

Is that possible?


Reply