When I am converting milliseconds to date, its creating a wrong date.
Number of milliseconds : 1460226660, which is actually: 10 april 2016. But it's showing me the following date : 17 January 1970, when I tried new Date(1460226660);
When I am converting milliseconds to date, its creating a wrong date.
Number of milliseconds : 1460226660, which is actually: 10 april 2016. But it's showing me the following date : 17 January 1970, when I tried new Date(1460226660);
Share Improve this question edited Mar 15, 2016 at 11:35 Sotiris Kiritsis 3,3563 gold badges24 silver badges31 bronze badges asked Mar 15, 2016 at 11:31 NirajNiraj 1632 silver badges12 bronze badges 3-
3
new Date(2016, 03, 10).valueOf()
-> 1460242800000. Your original value is wrong. – James Thorpe Commented Mar 15, 2016 at 11:32 - i took help of this which is showing me right date. timestampconvert./… – Niraj Commented Mar 15, 2016 at 11:34
- Your value is number of seconds, treated as milliseconds. It is out by a factor of 1000. – sideroxylon Commented Mar 15, 2016 at 11:35
2 Answers
Reset to default 6I think your value is in seconds, not milliseconds, so try multiply it by 1000.
new Date(1460226660 * 1000)
Your value 1460226660
are seconds and not milliseconds.
var date = new Date(1460226660 * 1000);
document.write(date.toDateString());