function pad(num, size) {
var s = num + "";
while (s.length < size) s = "0" + s;
return s;
}
function formatDateForCRM(date) {
var delta = (date.getHours() * 60 + date.getMinutes()) - (date.getUTCHours() * 60 + date.getUTCMinutes());
var deltaS = "+";
if (delta < 0) { deltaS = "-"; delta = 0 - delta; }
var deltaM = (delta % 60);
var deltaH = (delta - deltaM) / 60;
var DateFilter = "datetime\'";
DateFilter += pad(date.getUTCFullYear(), 4) + "-";
DateFilter += pad(date.getUTCMonth() + 1, 2) + "-";
DateFilter += pad(date.getUTCDate(), 2);
DateFilter += "T";
DateFilter += pad(date.getUTCHours(), 2) + ":";
DateFilter += pad(date.getUTCMinutes(), 2) + ":";
DateFilter += pad(date.getUTCSeconds(), 2);
DateFilter += deltaS + pad(deltaH, 2) + ":" + pad(deltaM, 2);
return DateFilter;
}
var X = new Date();
var S = formatDateForCRM(X);
print(S);
No comments:
Post a Comment