Minimum and maximum date

Viewed 213004

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.

5 Answers

A small correction of the accepted answer; the year of the minimum date is actually 271,822 BCE, as you can see when running the following snippet:

console.log(new Date(-8640000000000000).toLocaleString("en", {"year": "numeric", "era": "short"}))

Indeed, year -271,821 is actually 271,822 BCE because JavaScript's Date (along with ISO 8601) uses astronomical year numbering, which uses a year zero. Thus, year 1 is 1 CE, year 0 is 1 BCE, year -1 is 2 BCE, etc.

var startingDate = new Date().toISOString().split('T')[0] + "T00:00:00.001Z"; // for 2022-07-25 00 00 00 var endingDate = new Date().toISOString().split('T')[0] + "T23:59:59.999Z" ;

As you can see, 01/01/1970 returns 0, which means it is the lowest possible date.

new Date('1970-01-01Z00:00:00:000') //returns Thu Jan 01 1970 01:00:00 GMT+0100 (Central European Standard Time)
new Date('1970-01-01Z00:00:00:000').getTime() //returns 0
new Date('1970-01-01Z00:00:00:001').getTime() //returns 1
Related