0

I am taking date only field in ECMA script but while set_item stores the value one day off.

How to set it with the current selected date?

0

SharePoint expects the dates sent back to it via the Client Object Model to be in UTC time zone.

var isoDate = SP.TimeZone.localTimeToUTC(yourdatefield).toString();
 oListItem.set_item('date', isoDate);

This will set it with current selected date.

10
  • I am using it in SharePoint 2010 and getting SP.TimeZone undefined
    – rohitnsk
    May 2 '14 at 7:34
  • var tmpDate= new Date(yourDate); tmpDate= tmpDate.toISOString();var isoDate = SP.TimeZone.localTimeToUTC(tmpDate).toString(); oListItem.set_item('date', isoDate);
    – Anuja
    May 2 '14 at 8:14
  • Thanks Anuja.But SP.TimeZone function is not available in 2010 it is only in 2013.
    – rohitnsk
    May 2 '14 at 8:25
  • SP.RegionalSettings.timeZone
    – Anuja
    May 2 '14 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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