I am trying to display the date from time stamp using JavaScript but not working please check my code and it’s not working due to string time but if i passed in number then it’s working but this time coming from API so i must need to do something here. can anyone please help me.
JavaScript
x
4
1
var timestamp = '1607110465663'
2
var date = new Date(timestamp);
3
console.log(date.getTime())
4
Advertisement
Answer
Parse string into int then…:
JavaScript
1
3
1
var timestamp = '1607110465663'
2
var date = new Date(parseInt(timestamp));
3
and use date object
JavaScript
1
2
1
console.log(date)
2