.UTC()
Published Jul 22, 2021Updated Sep 3, 2021
Contribute to Docs
The .UTC()
static method of Date
that returns a number value representing the number of milliseconds between the specified date and January 1, 1970, 00:00:00, Universal Time Coordinated. Will always be called as Date.UTC()
rather than called on an instance of date such as myDate.UTC()
.
Syntax
Date.UTC(year, month, day, hour, minute, second, millisecond);
year
(required): The year in four-digit format. If only two digits are specified, the year is assumed to be in twentieth century.month
(optional): The range is from0
to11
.day
(optional): The range is from1
to31
.hour
(optional): The range is from0
to23
.minute
(optional): The range is from0
to59
.second
(optional): The range is from0
to59
.millisecond
(optional): The range is from0
to999
.
Note: UTC, Universal Time Coordinated, is the time set by the World Time Standard.
Example 1
Return the number of milliseconds between the specified date and January 1, 1970, 00:00:00, universal time.
var midnight1971 = Date.UTC(1971, 00, 01, 0, 0, 0);console.log(midnight1971);// Output: 34214400000
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Free course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner Friendly15 hours