How to convert Date Time to UTC or GMT in JavaScript?

Use toISOString() to convert Date Time to UTC or GMT in Javascript. 

Sample code:
let currentDateTime = new Date();
console.log( 'currentDateTime is ' + currentDateTime );
console.log( 'currentDateTime in UTC is ' + currentDateTime.toISOString() );

Output:


No comments:

Post a Comment