To convert a JavaScript date to UTC, use the getUTCDate() method. JavaScript date getUTCDate() method returns the day of the month in the specified date according to universal time. The value returned by getUTCDate is an integer between 1 and 31.
You can try to run the following code to convert a date to UTC −
Example
<html> <head> <title>JavaScript getUTCDate Method</title> </head> <body> <script> var dt = new Date( "December 31, 2017 23:15:20" ); document.write("getUTCDate() : " + dt.getUTCDate() ); </script> </body> </html>
Output
getUTCDate() : 31