JavaScript Date.UTC() method returns the number of milliseconds since January 1, 1970, 00:00:00 UTC. The Date.UTC() method is “used to convert the specified date-time to UTC in milliseconds.”
Syntax
Date.UTC(year, month, day, hours, minutes, seconds, millisec)
Parameters
-
year:
- Type: Integer
- Description: Represents the year of the date. For years between 0 and 99, the method interprets them as 1900-1999. So,
Date.UTC(89, 0)
would be interpreted as January 1, 1989.
- month:
- Type: Integer
- Description: Represents the month of the year, starting from 0 for January to 11 for December.
- day (optional):
- Type: Integer
- Default:
1
- Description: Represents the day of the month. If omitted, it defaults to
1
.
- hour (optional):
- Type: Integer
- Default:
0
- Description: Represents the hour of the day from
0
to23
. If omitted, it defaults to0
.
- minute (optional):
- Type: Integer
- Default:
0
- Description: Represents the minute of the hour from
0
to59
. If omitted, it defaults to0
.
- second (optional):
- Type: Integer
- Default:
0
- Description: Represents the second of the minute from
0
to59
. If omitted, it defaults to0
.
-
millisecond (optional):
- Type: Integer
- Default:
0
- Description: Represents the milliseconds of the second, from
0
to999
. If omitted, it defaults to0
.
Return value
The Date.UTC() method returns the number of milliseconds since January 1, 1970, 00:00:00 UTC for the given date and time. This value can then be used to create a new Date object, representing that exact time in UTC.
Example 1: How to Convert a Date to UTC
let year = 2023;
let month = 7; // August (months are 0-indexed)
let day = 26;
let hour = 12;
let minute = 30;
let second = 45;
let utcMilliseconds = Date.UTC(year, month, day, hour, minute, second);
let dateFromUTC = new Date(utcMilliseconds);
console.log(dateFromUTC.toISOString());
Output
2023-08-26T12:30:45.000Z
Example 2: Printing UTC in milliseconds
let year = 2023;
let month = 7; // August (months are 0-indexed)
let day = 26;
let hour = 12;
let minute = 30;
let second = 45;
let utcMilliseconds = Date.UTC(year, month, day, hour, minute, second);
console.log(utcMilliseconds)
Output
1693053045000
Browser Compatibility
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
Convert Date to UTC Using toUTCString() Method
JavaScript toUTCString() method of the Date object is “used to convert a date to a string representation using the UTC time zone.”
// Assuming this is in local time
let localDate = new Date('2023-08-26T15:05:52');
console.log("Local Date:", localDate.toString());
let utcString = localDate.toUTCString();
console.log("UTC Date:", utcString);
Output
That’s it!
Related posts
JavaScript Date toLocaleDateString()
JavaScript Date toTimeString()

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.