# HPTTL

> Get the remaining time to live of hash fields, in milliseconds.

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

```
HPTTL key FIELDS numfields field [field ...]
```

- Group: Hash
- Complexity: O(N) where N is the number of fields given
- HotKV Cloud: all plans
- On-Premise: no license needed

`HPTTL` works like [HTTL](https://docs.hotkv.com/commands/httl/index.md), but reports the remaining time to
live of each listed field in milliseconds.

## Return value

An array with one integer per field, in the order given, under both RESP2 and
RESP3:

| Value | Meaning |
| --- | --- |
| `-2` | The field or the key does not exist. |
| `-1` | The field exists but has no time to live. |
| `0` or more | The remaining time to live in milliseconds. |

The errors are the same as for [HTTL](https://docs.hotkv.com/commands/httl/index.md).

## Examples

```
127.0.0.1:6379> HSET cache:7 body "<html>"
(integer) 1
127.0.0.1:6379> HPEXPIRE cache:7 5000 FIELDS 1 body
1) (integer) 1
127.0.0.1:6379> HPTTL cache:7 FIELDS 1 body
1) (integer) 4998
```

## Compatibility

Same as Redis 7.4. Valkey 8 does not have hash field expiration.

## See also

[HTTL](https://docs.hotkv.com/commands/httl/index.md), [HPEXPIRETIME](https://docs.hotkv.com/commands/hpexpiretime/index.md), [HPEXPIRE](https://docs.hotkv.com/commands/hpexpire/index.md),
[PTTL](https://docs.hotkv.com/commands/pttl/index.md)