{
  "schema_version": 2,
  "id": "commands/expireat",
  "title": "EXPIREAT",
  "url": "https://redis.io/docs/latest/commands/expireat/",
  "summary": "Sets the expiration time of a key to a Unix timestamp.",
  "since": "1.2.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:32+01:00",
  "page_type": "content",
  "content_hash": "66db828e59b7b5bf6d72b615590a73dabf159401cb7582b97e8641a753d2794b",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "`EXPIREAT` has the same effect and semantic as [`EXPIRE`](https://redis.io/docs/latest/commands/expire), but instead of\nspecifying the number of seconds representing the TTL (time to live), it takes\nan absolute [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time) (seconds since January 1, 1970). A\ntimestamp in the past will delete the key immediately.\n\nPlease for the specific semantics of the command refer to the documentation of\n[`EXPIRE`](https://redis.io/docs/latest/commands/expire)."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key.\n\n</details>\n\n<details open><summary><code>unix-time-seconds</code></summary>\n\nThe absolute expiration time as a Unix timestamp in seconds. A timestamp in the past deletes the key immediately.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "These options are mutually exclusive.\n\n<details open><summary><code>NX</code></summary>\n\nSet the expiry only when the key has no expiry.\n\n</details>\n\n<details open><summary><code>XX</code></summary>\n\nSet the expiry only when the key already has an expiry.\n\n</details>\n\n<details open><summary><code>GT</code></summary>\n\nSet the expiry only when the new expiry is greater than the current one. A non-volatile key is treated as an infinite TTL for the purpose of `GT`.\n\n</details>\n\n<details open><summary><code>LT</code></summary>\n\nSet the expiry only when the new expiry is less than the current one. A non-volatile key is treated as an infinite TTL for the purpose of `LT`.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> SET mykey \"Hello\"\nOK\nredis> EXISTS mykey\n(integer) 1\nredis> EXPIREAT mykey 1293840000\n(integer) 1\nredis> EXISTS mykey\n(integer) 0"
    },
    {
      "id": "details",
      "title": "Details",
      "role": "content",
      "text": ""
    },
    {
      "id": "background",
      "title": "Background",
      "role": "content",
      "text": "`EXPIREAT` was introduced in order to convert relative timeouts to absolute\ntimeouts for the AOF persistence mode.\nOf course, it can be used directly to specify that a given key should expire at\na given time in the future."
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n* [Integer reply](../../develop/reference/protocol-spec#integers): `0` if the timeout was not set; for example, the key doesn't exist, or the operation was skipped because of the provided arguments.\n* [Integer reply](../../develop/reference/protocol-spec#integers): `1` if the timeout was set.\n\n**RESP3:**\n\nOne of the following:\n* [Integer reply](../../develop/reference/protocol-spec#integers): `0` if the timeout was not set; for example, the key doesn't exist, or the operation was skipped because of the provided arguments.\n* [Integer reply](../../develop/reference/protocol-spec#integers): `1` if the timeout was set."
    }
  ],
  "examples": []
}
