I'm using solana API and as a result of one function I get such response:
{
blockTime: 1646251782,
confirmationStatus: 'finalized',
err: null,
memo: null,
signature: 'xyz',
slot: 123192670
}
As you can see, there is blockTime
field, and I want to extract value from it. When I was doing it with moment
:
console.log(moment(1646251782).toISOString())
I got 1970 year, but it's incorrect, and I check this on solana explorer, and there was normal time. How can I get normal date or what do I do wrong?
This is unix
time in milliseconds, using moment you can extract time using this:
moment.unix(1650493606).format("YYYY-MM-DD HH:mm:ss")