Invalid time value error
See original GitHub issueError log
Invalid time value
Pass value fields
selected={‘03/07/2019’}
Using Version
react-datepicker": "^2.7.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
RangeError: Invalid time value - javascript
This exception occurs when the Date object contains an invalid date. new Date('undefined').toISOString(). In this example the Date object ...
Read more >RangeError: Invalid time value in JavaScript
The "Uncaught RangeError: Invalid time value" error occurs when calling a method on an invalid date, e.g. new Date('asdf').toISOString() .
Read more >RangeError: invalid date - JavaScript - MDN Web Docs
The JavaScript exception "invalid date" occurs when a string leading to an invalid date has been provided to Date or Date.parse() .
Read more >Invalid time value for field - - Common causes and quick fixes
Invalid time value for field - - Common causes and quick fixes. Prevent & resolve issues, cut down administration time & hardware costs....
Read more >I get an error "RangeError: Invalid time value"
I am getting the same error but nothing was changed on our server so it's not like it was something that updated on...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mtahirnawaz I figured it out. You have to put
selected={Date.parse('03/07/2019')}
I encountered this problem as well, @jylopez fix worked for me, too. Just to illustrate the situation -
In one context, I was setting the value of
selected
simply as the result ofnew Date()
, which would be something like:In those cases, I did not need to
.parse()
the data.However, sometimes I was populating the datepicker with data from the DB, which was received by the client as a UTC string like
2020-02-21T16:00:00.000Z
- passing that tonew Date()
would return:In those cases, I did need to
.parse()
the data - I assume there’s some discrepancy betweenEastern Daylight Time
andEastern Standard Time
.Anyway, I just made a point to parse whatever data the picker is receiving, and all is well.