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;
  const epoch = parseInt(date, 10);
  if (isNaN(epoch)) {
    var dateObject = new Date(date);

    if (dateObject.toString() === "Invalid Date") {
      res.json({ error: "Invalid Date" });
    } else {
      var returnObject = {
        unix: dateObject.valueOf(),
        utc: dateObject.toUTCString()
  } 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() };

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.

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"});

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