Issue in APIs and Microservices

So, I’m doing the microservice project where I have to get unix date timestamp . No test cases are being passed…

app.get("/api/timestamp/:date_string", function(req, res) {
  //   {"unix":1450137600000,"utc":"Tue, 15 Dec 2015 00:00:00 GMT"}
  var date = req.query.date_string;
  console.log(date);
  const epoch = parseInt(date, 10);
  console.log("Hello");
  if (isNaN(epoch)) {
    console.log("isNan");
    var dateObject = new Date(date);

    if (dateObject.toString() === "Invalid Date") {
      res.json({ error: "Invalid Date" });
    } else {
      var returnObject = {
        unix: dateObject.valueOf(),
        utc: dateObject.toUTCString()
      };
      res.json(returnObject);
    }
  } else {
//     if the returned is a number then convert into epoch and show the result..
    console.log("is else");
    var returnObject = { unix: epoch, utc: new Date(epoch).toUTCString() };
    res.json(returnObject);
  }
});


when I try to enter some query parameter in the URL like date_string=1450137600000
the unix timestamp changes to 1586061823000.
and that’s the reason why I think it is happening. How should I resolve this.
Thanks

1450137600000 would be the 13th of January 47923 anyway, so give it something sensible (your number is at least 1000 times bigger than it should be) and it will work.

So, I divide the number that I convert to int by 1000 and it should fix? I tried that but still no test cases are passed.

BTW i looked into the solution as well… and I modified my code it as the following

app.get("/api/timestamp/:date_string", function(req, res) {
  
  var dateString= req.query.date_string;
  
  if (/\d{5,}/.test(dateString)) {
  var  dateInt = parseInt(dateString);
    //Date regards numbers as unix timestamps, strings are processed differently
    res.json({ unix: dateString, utc: new Date(dateInt/1000).toUTCString() });
  }
  
  var dateObject= new Date(dateString);
  if(dateObject.toString()==="Invalid date"){ 
    res.json({error: "Invalid date"});
  }
  else{
    res.json({unix:dateObject.valueOf,utc:dateObject.toUTCString()})
  }
});

still no test cases are being passed… can you please tell me what am i doing wrong thanks.