A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-date-utc-method/ below:

JavaScript Date UTC() Method - GeeksforGeeks

JavaScript Date UTC() Method

Last Updated : 12 Jul, 2024

In JavaScript, the Date.UTC() method is used to create a date object representing a specified date and time in UTC (Coordinated Universal Time). It accepts the year, month, day, hour, minute, second, and millisecond components of the date and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC.

Syntax:
Date.UTC(year, month, day, hour, minute, second, millisecond);
Parameters: Return value:

The Date.UTC() method returns a number representing the number of milliseconds in the given Date object since January 1, 1970, 00:00:00, universal time.

Example 1: Below is an example of the Date UTC() method.

JavaScript
let gfg = Date.UTC(2020, 07, 03);
console.log("Output : " + gfg);

Output
Output : 1596412800000
Explanation:

The code creates a UTC date object representing August 3, 2020, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC. The value is then logged to the console.

Example 2: Three parameters are passed in the Date.UTC() method represents the year, month, and day respectively. The method returns the number of milliseconds between the date specified as the parameter and midnight of January 1, 1970.

JavaScript
let test = Date.UTC(2010, 01, 28);
console.log("Output : " + test);

Output
Output : 1267315200000
Explanation:

The code creates a UTC date object representing February 28, 2010, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC. The value is then logged to the console.

Supported Browsers:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4