Format a Date for InfoPath 2003
If you ever need to generate a date that is compliant with InfoPath 2003's date format (ISO 8601), here is the handy little function that appears throughout the InfoPath SDK code:
function GetDateString(oDate) {
// Use today as default value.
if (oDate == null)
oDate = new Date();
var m = oDate.getMonth() + 1;
var d = oDate.getDate();
if (m < 10)
m = "0" + m;
if (d < 10)
d = "0" + d;
// ISO 8601 date (YYYY-MM-DD).
return oDate.getFullYear() + "-" + m + "-" + d;
}