<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "Bitcoin",
  "identifier" : "/documentation/Bitcoin/UnixTimestamp",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Bitcoin"
    ],
    "preciseIdentifier" : "s:7Bitcoin13UnixTimestampV"
  },
  "title" : "UnixTimestamp"
}
-->

# UnixTimestamp

Unix epoch seconds. Decodes/encodes as `Int64`.

```
struct UnixTimestamp
```

## Overview

Used for Bitcoin Core `NUM_TIME` fields: `time`, `blocktime`, `mediantime`,
`lastsend`, `lastrecv`, `conntime`, etc.

```swift
let ts = UnixTimestamp(seconds: 1_700_000_000)
print(ts.date)        // 2023-11-14 22:13:20 +0000
print(ts.description) // ISO 8601 formatted string
```

> Note: Some Core fields use 0 as a sentinel for “not set” (e.g., genesis
> `mediantime`). Check `seconds == 0` at the call site where contextually
> appropriate, or use `Optional<UnixTimestamp>` for fields that can be absent.

> Note: `locktime` is **not** a `UnixTimestamp` — it’s dual-use (block height
> when < 500,000,000, epoch seconds when ≥ 500,000,000).

> Note: `getnettotals.timemillis` is epoch **milliseconds** and uses `Int64`.

> Note: `ban_duration` / `time_remaining` are durations in seconds, not
> epoch timestamps, and use `Int64`.