Skip to content

Instantly share code, notes, and snippets.

@AmitKB
Last active December 20, 2015 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmitKB/6054787 to your computer and use it in GitHub Desktop.
Save AmitKB/6054787 to your computer and use it in GitHub Desktop.
This converts the date format in mm/dd/yyyy to ISO date format to be used in MOSS 2007 / WSS 3.0
function ISODateString (stringDate){
function pad(n){return n<10 ? '0'+n : n}
function parseDate(input) {
var parts = input.split('/');
var y = parseInt(parts[2]);
var m = parseInt(parts[0]);
var d = parseInt(parts[1]);
// new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
var dt = new Date(y, m-1, d,0,0,0); // months are 0-based
return dt ;
}
var d = parseDate(stringDate);
var iso= d.getFullYear()+'-'
+ pad(d.getMonth()+1)+'-'
+ pad(d.getDate())+'T'
+ pad(d.getHours())+':'
+ pad(d.getMinutes())+':'
+ pad(d.getSeconds())+'Z';
return iso;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment