Back End Development and APIs Projects - Timestamp Microservice

Tell us what’s happening:
can’t understand the following testcase
test case 5 not getting passed:
i.e Your project can handle dates that can be successfully parsed by new Date(date_string)

my code :
app.get(“/api/:date”, (req, res) => {
let responseObject = {};

let date_string =;

if (date_string.includes(“-”)) {
responseObject[“unix”] = new Date(date_string).getTime();
responseObject[“utc”] = new Date(date_string).toUTCString();
} else if (!isNaN(date_string)) {
let input = parseInt(date_string);

responseObject["unix"] = new Date(input).getTime();
responseObject["utc"] = new Date(input).toUTCString();


if (!responseObject[“unix”] || !responseObject[“utc”]) {
res.json({ error: “Invalid date” });
} else {
// route to handle endpoint with empty parameter
app.get(“/api”, (req, res) => {
let responseObject = {};

responseObject[“unix”] = new Date().getTime();
responseObject[“utc”] = new Date().toUTCString();


Your project link(s)

solution: boilerplate-project-timestamp - Replit

Your browser information:

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

Challenge: Back End Development and APIs Projects - Timestamp Microservice

Link to the challenge:

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