Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Need Help Using UpdateListItems

$
0
0
Great solution from Gkoliver, just to add though I believe Sharepoint requires the time values to be double digits and when saving to a Sharepoint list I received errors when the seconds were in single digits (not sure about hours and minutes but applied the same fix to those as well just in case.

By adding this method to the Number prototype you can call it within Gkoliver's convert date function to ensure each value is double digit
Number.prototype.digitise = function (val) 
{
    return (new Array( val + 1 ).join("0") + this ).slice( - val );
}
So it would become ...
function ConvertDateToISO(dtDate)
{
//*************************************************
//Converts Javascript dtDate to ISO 8601 standard for compatibility with SharePoint lists
//Inputs: dtDate = Javascript date format (optional)
//*************************************************
  var d;
  if (dtDate != null)  {
     //Date value supplied
     d = dtDate;
  }
  else  {
     //No date supplied, Create new date object
     d = new Date();
  }
  //Generate ISO 8601 date/time formatted string
  var s = "";
  s += d.getYear() + "-";
  s += d.getMonth() + 1 + "-";
  s += d.getDate();
  s += "T" + d.getHours().digitise(2) + ":";
  s += d.getMinutes().digitise(2) + ":";
  //Replace the "Z" below with the required
  //time zone offset (eg "+10:00" - Australian EST)
  s += d.getSeconds().digitise(2) + "Z";
  //Return the ISO8601 date string
  return s;
}

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>