JavaScript Date toUTCString() method - JavaScript Tutorial

JavaScript Date toUTCString() method

BLUF: This tutorial on JavaScript Date toUTCString() method provides an in-depth look at JavaScript's core features. It includes practical examples and code snippets to help you master modern JS development.
Key Discovery: JavaScript Date toUTCString() method

Understanding JavaScript Date toUTCString() method is crucial for building dynamic, interactive web applications. Explore the examples below to see it in action.

The toUTCString method in JavaScript provides the specified date as a string formatted according to the UTC time zone.

Syntax

The syntax for the toUTCString method is illustrated as follows:

Example

dateObj.toUTCString()

Return

A string representing the specified date.

JavaScript Date toUTCString method example

In this section, we will explore the toUTCString method by examining a variety of examples.

Example 1

Let’s examine an illustration of how to retrieve the current date represented as a string.

Example

<script>

var date=new Date();

document.writeln(date.toUTCString());

</script>

Output:

Output

Thu, 09 Aug 2018 11:41:19 GMT

Example 2

Let’s examine an example that retrieves a particular date represented as a string.

Example

<script>

var date=new Date(1947, 7, 15, 20, 22, 10);

document.writeln(date.toUTCString());

</script>

Output:

Output

Fri, 15 Aug 1947 14:52:10 GMT

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience