JavaScript Date to UTC Format
new Date().toISOString()
> '2012-11-04T14:51:06.157Z'
VoiceTechGuy
new Date().toISOString()
> '2012-11-04T14:51:06.157Z'
function utcformat(d){
d= new Date(d);
var tail= 'GMT', D= [d.getUTCFullYear(), d.getUTCMonth()+1, d.getUTCDate()],
T= [d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds()];
if(+T[0]> 12){
T[0]-= 12;
tail= ' pm '+tail;
}
else tail= ' am '+tail;
var i= 3;
while(i){
--i;
if(D[i]<10) D[i]= '0'+D[i];
if(T[i]<10) T[i]= '0'+T[i];
}
return D.join('/')+' '+T.join(':')+ tail;
}
var UTCdate = new Date('4/29/2021 3:22:46 PM UTC');
console.log(UTCdate)
// console.log(new Date('2020-1-1'+'UTC'));
// output
// Thu Apr 29 2021 21:07:46 GMT+0545 (Nepal Time)