I don't know if this is the better way to do it, but I hope this helps,
<script type="text/javascript">
var fulldate = new Date();
y = fulldate.getFullYear();
m = (fulldate.getUTCMonth()) + 1;
if(m<10){m='0'+m;}
d = fulldate.getUTCDate();
if(d<10){d='0'+d;}
h = fulldate.getUTCHours();
if(h<10){h='0'+h;}
mt = fulldate.getUTCMinutes();
if(mt<10){mt='0'+mt;}
s = fulldate.getUTCSeconds();
if(s<10){s='0'+s;}
c = fulldate.getUTCMilliseconds()+'';
c = c.substr(0,2);
alert(y+'-'+m+'-'+d+'T'+h+':'+mt+':'+s+'.'+c+'Z');
</script>