How to convert a date to a string using the universal time convention?


To convert a date to a string using the universal time convention, use the toUTCString() method. It returns converted the date to a string, using the universal time convention.

Example

You can try to run the following code to learn how to convert a date to a string using UTC −

<html>
   <head>
      <title>JavaScript toUTCString Method</title>
   </head>
   <body>
      <script>
         var dateobject = new Date(2018, 0, 15, 14, 39, 7);
         document.write( dateobject.toUTCString() );
      </script>
   </body>
</html>

Updated on: 23-Jun-2020

89 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements