Last active
December 20, 2015 02:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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