Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 492
user3736648 Avatar asked Feb 10 '15 07:02

user3736648


People also ask

Is there a date data type in JavaScript?

JavaScript does not have a date data type. However, you can use the Date object and its methods to work with dates and times in your applications. The Date object has a large number of methods for setting, getting, and manipulating dates. It does not have any properties.

What is $$ in JavaScript?

$ and $$ are valid variable names in JavaScript, they have no special meaning. Usually they set their value to library instances, in your example if you check the closure call, at the end of the file you'll see that $ is jQuery in this case if it is defined and $$ is cytoscape.

What is the minimum date value?

Remarks. The value of this constant is equivalent to 00:00:00.0000000 UTC, January 1, 0001, in the Gregorian calendar. MinValue defines the date and time that is assigned to an uninitialized DateTime variable.


1 Answers

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.

like image 139
rgajrawala Avatar answered Oct 17 '22 06:10

rgajrawala