0

I am trying the below code , but my Date is not printing properly. I am getting some different number for year.

 const date= = new Date(1607056200000 * 1000);
 let convDate = date.toLocaleDateString("en-US");
 console.log("Date is " + convDate + "\n");

The output I got is

   Date is 8/1/52895

But when I tried running the below code, I got correct date and time output

let Time = new Intl.DateTimeFormat("en-US", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit",
            hour: "2-digit",
            minute: "2-digit",
            second: "2-digit",
          }).format(1607056200000);
          console.log("Time is" + Time + "\n");

Output I got

Time is 12/04/2020, 10:00:00 AM

Can anyone tell me where I am going wrong?

Nida_100
  • 1
  • 1

0 Answers0