// to UTC/JSON Date
Number.prototype.addZero = function () { return (this < 10) ? "0" +
this : this; };
var convertDate = function (d) {
var d, s, u, uh, um, us;
//d = new Date();
s = d.getFullYear() + "-";
s += (d.getMonth() + 1).addZero() + "-"; //getMonth returns an
integer in the range 0-11
s += d.getDate().addZero() + "T";
s += d.getHours().addZero() + ":";
s += d.getMinutes().addZero() + ":";
s += d.getSeconds().addZero();
u = 0 - d.getTimezoneOffset(); //getTimezoneOffset will
be positive if you are behind UTC, and negative if you are ahead of
UTC.
us = (u >= 0) ? "+" : "-";
u = Math.abs(u);
uh = Math.floor(u / 60).addZero();
um = (u % 60).addZero();
s += us;
s += uh + ":";
s += um;
alert(s);
return (s);
};
// call
convertDate(new Date());