JavaScript toUTCString() | Get the Complete Date as String according to UTC

The JavaScript toUTCString() method is used to get the complete date as string based on the Universal Time Coordinated (UTC) or Greenwich Mean Time (GMT). For example:

HTML with JavaScript Code
<!DOCTYPE html>
<html>
<body>
   
   <p id="xyz"></p>

   <script>
      const d = new Date();
      let dateUTC = d.toUTCString();
      document.getElementById("xyz").innerHTML = dateUTC;
   </script>

</body>
</html>
Output

JavaScript toUTCString() Syntax

The syntax of toUTCString() method in JavaScript is:

x.toUTCString()

where x must be an object of the Date() constructor.

The toUTCString() method returns a string representing the UTC date and time.

Please note: To display date in format dd-mm-yyyy, refer to its separate example.

Please note: To display time in format hh:mm:ss, refer to its separate example.

Please note: To display time in format hh:mm:ss AM/PM, refer to its separate example.

JavaScript Online Test


« Previous Tutorial Next Tutorial »