Rangeerror: Invalid Time Value

Rangeerror: Invalid Time Value

I'm getting frequent errors when i start my server. Here is the error:

RangeError: Invalid time value at Date.toISOString ()

Here is the code:

var start = timestamp;
const expiryDate = (new Date(start)).toISOString().split('T')[0];
4

1 Answer

This exception occurs when the Date object contains an invalid date.

new Date('undefined').toISOString()

In this example the Date object can be created without any problems, but the toISOString function throws an Error.

To fix your issue, you need to make sure that the timestamp variable contains a valid date string.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.