Timestamp Microservice on the two test of empty date

Here is my code

app.get("/api", function (req, res) {
const now = new Date();
  res.json({ unix: now.getTime(), utc: now.toUTCString() });

app.get("/api/:date", function (req, res) {
    const { date } = req.params;
    const timestamp = parseInt(date * 1, 10);
    const finalDate = new Date(timestamp || date || Date.now());

    let result;

        if (isNaN(+finalDate)) {
            result = { error: "Invalid Date" };
        } else {
            result = {
                unix: finalDate.getTime(),
                utc: finalDate.toUTCString(),

i have tried every things, all tests are working fine but the two tests with an empty date always fail, i have read some discussion on the forums and even change the timezone of my computer which was UTC +2 to UTC and try again the tests but nothing works!!
can you please help me with this issue

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36

Challenge: Timestamp Microservice

Link to the challenge:

I checked your code and it passes for me.
Can you post the response you’re getting for the failing tests?

Here is the test page

I mean open dev tools (F12), select Network tab and select one of the last two requests:

i captured this yesterday

Tests allow for tolerance of ±20 seconds, so only thing I can think of is that server time is off by more than 20 seconds.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.