I was playing around with timestamps in mongoose, and noticed that it fills createdAt and updatedAt field with date like "createdAt": "2021-07-01T04:34:11.971Z". When I created my own createdAt field using Date.now, it filled it with epoch. I want to convert the epoch (1625116723801) to a Date format like the one created by timestamps. For this, I performed the following steps.
const epoch = 1625116723801
const d = Date(epoch*1000)
console.log(d)
It returned me Date like this: +053375-06-09T15:01:04.000Z
const epoch = 1625116723801
const d = Date(epoch*1000)
console.log(d)
It returned me Date like this: ** Thu Jul 01 2021 10:50:11 GMT+0530 (India Standard Time) **
How can I get the format like that of timestamps?