I have been searching to find a good way to convert Date object into formatted string but couldn't find quite an answer.
input value is this
1402462980000
and I output value should be in this format
dddd-dd-ddTdd:dd:dd[-,+]dd:dd
E.g., 2014-06-11T15:03:00+10:00
and the only way I can think of is doing it manually
tmpDate = new Date(1402462980000);
s1 = tmpDate.getFullYear().toString();
s2 = ('0' + tmpDate.getMonth()).slice(-2);
s3 = ('0' + tmpDate.getDate()).slice(-2);
s4 = ('0' + tmpDate.getHours()).slice(-2);
s5 = ('0' + tmpDate.getMinutes()).slice(-2);
s6 = ('0' + tmpDate.getSeconds()).slice(-2);
s7 = ('0' + (tmpDate.getHours() - tmpDate.getUTCHours())).slice(-2);
s8 = ('0' + (tmpDate.getMinutes() - tmpDate.getUTCMinutes())).slice(-2);
s1 + '-' + s2 + '-' + s3 + 'T' + s4 + ':' + s5 + ':' + s6 + '+' + s7 + ':' + s8;
and this looks a little crazy to me. I'm thinking there must be a better way. if you know please share your knowledge :) Thanks.