{
  "schema_version": 2,
  "id": "commands/pttl",
  "title": "PTTL",
  "url": "https://redis.io/docs/latest/commands/pttl/",
  "summary": "Returns the expiration time in milliseconds of a key.",
  "since": "2.6.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": "a1b38dedd4b8f6e4b4c6efbd3ab9bf0963fddbf1373dc2fe0b3fda38210f7fab",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Like [`TTL`](https://redis.io/docs/latest/commands/ttl) this command returns the remaining time to live of a key that has an\nexpire set, with the sole difference that [`TTL`](https://redis.io/docs/latest/commands/ttl) returns the amount of remaining\ntime in seconds while `PTTL` returns it in milliseconds.\n\nIn Redis 2.6 or older the command returns `-1` if the key does not exist or if the key exist but has no associated expire.\n\nStarting with Redis 2.8 the return value in case of error changed:\n\n* The command returns `-2` if the key does not exist.\n* The command returns `-1` if the key exists but has no associated 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>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> SET mykey \"Hello\"\nOK\nredis> EXPIRE mykey 1\n(integer) 1\nredis> PTTL mykey\n(integer) 1000"
    },
    {
      "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): TTL in milliseconds.\n* [Integer reply](../../develop/reference/protocol-spec#integers): `-1` if the key exists but has no associated expiration.\n* [Integer reply](../../develop/reference/protocol-spec#integers): `-2` if the key does not exist.\n\n**RESP3:**\n\nOne of the following:\n* [Integer reply](../../develop/reference/protocol-spec#integers): TTL in milliseconds.\n* [Integer reply](../../develop/reference/protocol-spec#integers): `-1` if the key exists but has no associated expiration.\n* [Integer reply](../../develop/reference/protocol-spec#integers): `-2` if the key does not exist."
    }
  ],
  "examples": []
}
