Javascript date format like ISO but local
<p>how do I format a javascript date like ISO format, but in local time?</p>

<p>with <code>myDate.toISOString()</code> I am getting the time as: "2012-09-13T19:12:23.826Z"</p>

<p>but here, it is 22:13, so how do I include the timezone in above format?</p>

<hr>

<p>I ended up doing...</p>

<pre><code>pad=function(e,t,n){n=n||"0",t=t||2;while((""+e).length&lt;t)e=n+e;return e}
c = new Date()
c.getFullYear()+"-"+pad(c.getMonth()+1)+"-"+pad(c.getDate()-5)+"T"+c.toLocaleTimeString().replace(/\D/g,':')+"."+pad(c.getMilliseconds(),3)
</code></pre>
