DateTime/timestamp of the transaction

How can I get the DateTime/timestamp of the transaction?

There is a timestamp field in the transaction JSON returned by the APIs that return transactions

hello, thank you for your answer but I don't understand how to get this date [8/21/2021 22:04:15] from
this response

{"signature":"2b52870bd734a57e5f5742a47d4a96de47fe60ee6aff2f821900c9b35287f00b5a662627a7f980fe1e985590f70fee0be8506c52de4f54bc634c700eb8a1e5d8","transactionIndex":0,"type":0,"phased":false,"ecBlockId":"18008105908473250369","signatureHash":"07698a9b6946db6d557e150de86468dbbd8b70b3f8be728b84778d8eadcd8c58","attachment":{"version.OrdinaryPayment":0},"senderRS":"VCP-WRZL-KJ5Q-95EH-8ALRK","subtype":0,"amountNQT":"200000000","recipientRS":"VCP-EYU2-N4D7-ZUPU-45QZU","block":"7893084217470826556","blockTimestamp":10383845,"deadline":60,"timestamp":10383856,"height":68605,"senderPublicKey":"7d837a433f573f8ae625ea73a3139a470f83888d83e937dd22b5bc78fa93be64","feeNQT":"10000000","requestProcessingTime":0,"confirmations":42,"fullHash":"a214e05597eff93f3c5cfe0d8a7f2a6b28da95f9143ed71fde9740ccdb867646","version":1,"sender":"7556556991031566322","recipient":"3278272673256733504","ecBlockHeight":67884,"transaction":"4609979126850262178"}

is the timestamp expressed in seconds?

Yes, timestamp is number of seconds since the epochBeginning. The epochBeginning is returned by the getConstants API and is in milliseconds since 1 January 1970 UTC. On mainnet epochBeginning represents 2018-01-01 00:00:00 and on testnet 2017-12-26 14:00:00.

Check the function NRS.fromEpochTime in nrs.util.js about how to convert from Ardor timestamp to the milliseconds since 1 January 1970 UTC format, which can then be used to create a new javascript Date object and then e.g. print it as string.

Hi, I got the "epochBeginning" from my server's constants, How can I convert timestamp to the correct date from getTransaction response via API. I'm using xamarin in developing my app.

I think there is missing in my conversion coz it is giving an incorrect transaction date.

Just add the epoch beginning (milliseconds) to the transaction timestamp (seconds) adjusting to the desired unit and convert that. The specific conversion will depend on your language and platform.

@sergi and @petko.petkov Thanks, Got the correct date now! :blush::blush::blush::blush:

2 Likes