# PTTL

> Return a key's remaining time to live in milliseconds.

URL: https://docs.hotkv.com/commands/pttl/

```
PTTL key
```

- Group: Keys
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`PTTL` returns how many milliseconds are left before `key` expires. Reading
the time to live is not an access to the key.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| The key has a time to live | Integer: milliseconds left | Integer |
| The key exists without a time to live | Integer `-1` | Integer `-1` |
| The key does not exist | Integer `-2` | Integer `-2` |

## Examples

```
127.0.0.1:6379> SET token "x" PX 2500
OK
127.0.0.1:6379> PTTL token
(integer) 2498
127.0.0.1:6379> PTTL missing
(integer) -2
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[TTL](https://docs.hotkv.com/commands/ttl/index.md), [NTTL](https://docs.hotkv.com/commands/nttl/index.md),
[PEXPIRETIME](https://docs.hotkv.com/commands/pexpiretime/index.md), [PEXPIRE](https://docs.hotkv.com/commands/pexpire/index.md)