JavaScript What is the furthest date that can be represented by a JS Date? [duplicate]

I was wondering which is the minimum and the maximum date allowed for a Javascript Date object. I found that the minimum date is something like 200000 B.C., but I couldn't get any reference about it.

Does anyone know the answer? I just hope that it doesn't depend on the browser.

An answer in "epoch time" (= milliseconds from 1970-01-01 00:00:00 UTC+00) would be the best.

Answer:1

To augment T.J.'s answer, exceeding the min/max values generates an Invalid Date.

let maxDate = new Date(8640000000000000);
let minDate = new Date(-8640000000000000);

console.log(new Date(maxDate.getTime()).toString());
console.log(new Date(maxDate.getTime() - 1).toString());
console.log(new Date(maxDate.getTime() + 1).toString()); // Invalid Date

console.log(new Date(minDate.getTime()).toString());
console.log(new Date(minDate.getTime() + 1).toString());
console.log(new Date(minDate.getTime() - 1).toString()); // Invalid Date
Answer:2

I'm writing a lua script that I want to use with scrapy + splash for a website. I want to write a script that enters a text and then clicks on a button. I have the following code: function main(...

I'm writing a lua script that I want to use with scrapy + splash for a website. I want to write a script that enters a text and then clicks on a button. I have the following code: function main(...

app.js var bodyParser = require('koa-bodyparser'); app.use(bodyParser()); app.use(route.get('/objects/', objects.all)); objects.js module.exports.all = function * all(next) { this.body = yield ...

app.js var bodyParser = require('koa-bodyparser'); app.use(bodyParser()); app.use(route.get('/objects/', objects.all)); objects.js module.exports.all = function * all(next) { this.body = yield ...

  1. query string with multiple parameters
  2. query string with spaces
  3. query string with array
  4. query string with #
  5. query string with no value
  6. query string with ampersand
  7. query string with filter in elasticsearch
  8. query string with multiple parameters in c#
  9. query string with special characters
  10. query string with forward slash
  11. query string with parameters
  12. query string with hash
  13. query string with post
  14. query string with slash
  15. query string with spaces c#
  16. query string with plus sign
  17. query string with anchor tag
  18. query string with multiple parameters in javascript

I want to display products unit of measurement at the frontend. For that I have created weight_unit attribute in admin panel and I am adding it to products like gram, kilogram, liter, etc. But I can't ...

I want to display products unit of measurement at the frontend. For that I have created weight_unit attribute in admin panel and I am adding it to products like gram, kilogram, liter, etc. But I can't ...

  1. product display unit
  2. display unit product buy
  3. retail product display unit/shelves
  4. portable product display unit

I have a function that returns JSON objects using hnews.getById(id). I then push each story returned in the promise to an array. I'm having trouble figuring out how I'd then get the complete array. Do ...

I have a function that returns JSON objects using hnews.getById(id). I then push each story returned in the promise to an array. I'm having trouble figuring out how I'd then get the complete array. Do ...