Simon
Simon

Reputation: 8347

Javascript Date MAX_VALUE

In JavaScript, what is the maximum value for the year in a Date?

How can I find this out in code?

I have tried the following:

new Date().getFullYear().MAX_VALUE;

Thanks in advance.

Upvotes: 11

Views: 18534

Answers (1)

rgajrawala
rgajrawala

Reputation: 2188

As per specs here: https://262.ecma-international.org/11.0/#sec-time-values-and-time-range : The actual range of times is 8,640,000,000,000,000 milliseconds to either side of 01 January, 1970 UTC. So, the maximum valid year you will get is 275760 (new Date(8640000000000000).getFullYear()). And to get the minimum valid year, new Date(-8640000000000000).getFullYear() or 271821 B.C.E.

Upvotes: 23

Related Questions