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(),
};
}
res.json(result);
});
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: