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

HTMLJavascriptProgramming Scripts

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>
raja
Published on 26-Feb-2018 11:42:46
Advertisements