question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid time value error

See original GitHub issue

Error log Invalid time value Pass value fields selected={‘03/07/2019’} Using Version react-datepicker": "^2.7.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

54reactions
jylopezcommented, Jul 5, 2019

@mtahirnawaz I figured it out. You have to put selected={Date.parse('03/07/2019')}

2reactions
darrenkleincommented, Mar 14, 2020

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 of new Date(), which would be something like:

Thu Mar 12 2020 14:47:32 GMT-0400 (Eastern Daylight Time)

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 to new Date() would return:

Fri Feb 21 2020 11:00:00 GMT-0500 (Eastern Standard Time)

In those cases, I did need to .parse() the data - I assume there’s some discrepancy between Eastern Daylight Time and Eastern Standard Time.

Anyway, I just made a point to parse whatever data the picker is receiving, and all is well.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found