Skip to content
Advertisement

Display time from string timestamp in javascript

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.

var timestamp = '1607110465663'
var date = new Date(timestamp);
console.log(date.getTime())

Advertisement

Answer

Parse string into int then…:

var timestamp = '1607110465663'
var date = new Date(parseInt(timestamp));

and use date object

console.log(date)
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement