JS: Date.UTC

By Xah Lee. Date: . Last updated: .

Date.UTC ( year, month , date , hours , minutes , seconds , ms )

The year and month arguments are required.

If less than 2 arguments are given, result is implementation dependent.

Return the milliseconds representation of current datetime. Sample return value: 1428601360919

The parameters are exactly the same as the mulitple number type parameters version of new Date(…), but interprets them as UTC.

[see JS: Date Constructor]

Other parameter form such as Date.UTC() or Date.UTC(string) are not allowed.

const d = Date.UTC ( 2016, 12 , 17 );
console.log ( d ); // 1484611200000
console.log ( (new Date(d)).toString() ); // Mon Jan 16 2017 16:00:00 GMT-0800 (PST)
// these parameters are not allowed
console.log ( Date.UTC () === NaN ); // true
console.log ( Date.UTC ("2015-04-08T15:48:22.000Z") === NaN ); // true

Reference

ECMAScript 2015 §Numbers and Dates#sec-date.utc

Date Topic

  1. JS: Date Tutorial
  2. JavaScript Date.parse
  3. JS: Compute Date Range

  1. JS: Date Object
  2. JS: Date Constructor
  3. JS: Date.prototype

JS Object Reference

  1. Global
  2. Object
  3. Array
  4. Function
  5. String
  6. RegExp
  7. Date
  8. Set
  9. Map
  10. JSON
  11. Math
  12. Reflect
  13. Number
  14. Boolean
  15. Symbol
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth