Skip to content
Related Articles

Related Articles

Improve Article

JavaScript RangeError – Invalid date

  • Last Updated : 23 Aug, 2020
Geek Week

This JavaScript exception invalid date occurs if the string that has been provided to Date or Date.parse() is not valid.

Message:

RangeError: invalid date (Edge)
RangeError: invalid date (Firefox)
RangeError: invalid time value (Chrome)
RangeError: Provided date is not in valid range (Chrome)

Error Type:

RangeError

Cause of the Error: An invalid date string is provided to Date or Date.parse() method in the code.

Example 1: In this example, the invalid string is provided, so the error has occurred.



HTML




<script>
new Date('2014-55-26').toISOString();
</script>

Output(In console):

RangeError: invalid time value

Example 2: In this example, the invalid string is provided, so the error has occurred.

HTML




<script>
var date = new Date('2020-57-16'); // Error here
date.toISOString();
</script>

Output(In console):

RangeError: invalid time value

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it’s lowest price ever!

My Personal Notes arrow_drop_up
Recommended Articles
Page :