I'm using timestamp that is inserted into my PostreSQL database & trying to parse it to become user friendly, however I'm getting the wrong year?
function toTimestamp(strDate){ var datum = Date.parse(strDate); return datum/1000; } let timestamp = toTimestamp('Sun Jan 19 2020 21:19:40 GMT+0000 (Coordinated Universal Time)'); var d = new Date(); d.setTime(timestamp); console.log(d.toGMTString()); //Mon, 19 Jan 1970 06:44:28 GMT I'm expecting a result of Sun, 19 Jan 2020 21:19:40 GMT
var d = new Date(timestamp)(once you stop dividing by 1000).