0

I've got a hex string, 0x63a4b534, I'd like to convert to a human readable date. However, I'm not sure how to do that. I've tried:

new Date("0x63a4b534").toLocaleDateString() 

to no avail.

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
Furkan Öztürk
  • 441
  • 4
  • 21

2 Answers2

1
// eth timestamp is in seconds. this will give you seconds
const timeInSeconds=parseInt('0x63a4b534',16)
// convert to miliseconds
const timeInMiliseconds=timeInSeconds*1000
const currentTime=new Date(timeInMiliseconds).toLocaleDateString()
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
0

Found an answer and was close. https://stackoverflow.com/a/847196/15018688

new Date("0x63a4b534".toNumber() * 1000).toLocaleDateString()

Furkan Öztürk
  • 441
  • 4
  • 21