Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am displaying User field 'date of hire' in table via remoting. On my end it shows correctly but on client's side date is displayed one day before. I doubt something wrong is occurring in javascript. below is the javascript code.

var formatdate = new Date(response[i].date_Of_Hire__c);
if(formatdate != 'Invalid Date')
{
    hireDate = month_name[formatdate.getMonth()]+" "+formatdate.getDate()+",       "+formatdate.getFullYear();
}

Please suggest what am I doing wrong here?

Thanks in advance.

share|improve this question
1  
What is your UTC offset. It is likely that the value being transferred is in UTC. –  Daniel Ballinger May 26 at 9:37

1 Answer 1

up vote 4 down vote accepted

The issue is most likely the transfer of Dates in the UTC timezone rather than the browsers timezone or that of the Salesforce User. Note that Salesforce stores the values in UTC and then converts them for display based on the current users timezone offset.

There is a Javascript function in Convert UTC date time to local date time using JavaScript that will convert from UTC to the browsers reported timezone offset.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.