app.get("/api/timestamp/:date_string?", (req,res) => {
date_string = req.params.date_string;
if(!date_string) { //If there is no parameter
date = new Date();
res.json({"unix": date.getTime(), "utc": date.toUTCString()});
}
else
{
if(!isNaN(date_string)) //If the parameter is a date in milliseconds
date = new Date(Number(date_string));
else
date = new Date(date_string);
if(date instanceof Date && !isNaN(date)) //If the date is valid
res.json({"unix": date.getTime(), "utc": date.toUTCString()});
else
res.json({"error" : "Invalid Date" });
}
});
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36.
I can’t get your live project page to display (bad response with SSL error in chrome), and I would bet it’s something to do with the missing braces in this block.
You’re correct. I should have checked first, but I thought (hoped) that only worked with a one-line if statement. I always use braces and try to forget that you don’t have too.
I have no idea why it would not be registered as long as it passed the tests and you clicked the submit and go to next project button.