Why is the date decades off when I directly convert an XRP Ledger timestamp?
First, confirm when the field’s timekeeping starts. The Ripple Epoch in XRPL documentation starts at 00:00 UTC on January 1, 2000, which is 946684800 seconds later than the Unix epoch. If you pass the raw value directly to a Unix date function, the result will be decades too early.
For example, if you read a check’s raw expiration time from the ledger, first confirm that the field uses the Ripple Epoch. If it does, add this offset to the raw number of seconds, then convert it using a Unix time function. Use dates that a browser or API has already converted as-is to avoid adding the offset twice.
When generating order reports, you can save the original value, the time origin, and the converted UTC date at the same time. The official documentation also warns against using a 32-bit variable for this conversion to avoid overflow.
$XRP #XRPL
Source material https://xrpl.org/docs/references/protocol/data-types/basic-data-types