I am using Date
to convert unix milliseconds epoch to a date.
So 1501783442 == Tuesday, 8 August 2017 12:35:57
.
But javascript says its
Sun Jan 18 1970 14:39:43 GMT+0530 (IST)
.
<p id="demo"></p>
<script>
var d = new Date(1501783442);
document.getElementById("demo").innerHTML = d;
</script>
Jsfiddle link.
Whats going on here?
Date.now()
(eg1502197442246
) has three additional digits. Try multiplying by 1000...