I had a similar issue when working on this project. In my case, I noticed that the FCC version of the service and my version differed on a specific date_string format due to the time zone being assumed. If you look at the documentation for Date.parse() on Mozilla (see the following: Date.parse()), one of the date_string formats accepted by the parse() method assumes the time is based on the local time zone where your machine is physically. If you want to correct it to use GMT, you can convert the date_string to an ISO format date_string, or handle it manually a different way.
I’m assuming there’s probably an easier and better solution for this, but since using the ISO format worked for me, I didn’t pursue any other options.
You’re doing a lot of unnecessary work parsing the string.
In the case that you’re given milliseconds like in /api/1451001600000, convert req.params.date to a number, then pass that number straight into new Date().
In the case that you’re given anything else, toss req.params.date straight into new Date().
An easy way to test if something converts cleanly to a number without regular expressions is something like this using the Number constructor.
const someNum = Number(someString);
if (Number.isNaN(someNum)) {
// someString couldn't convert to a number
}
Hi brother…I’ve been stuck for hours on this project. Can you plsss reply with the code that passed the test or can you kindly take your time to email me muhammedko420@gmail…thinking the answer might be blocked here. Thanks