## `getBlockTimestamp`

### Signature

```solidity
function getBlockTimestamp() external view returns (uint256 timestamp);
```

### Description

Gets the current `block.timestamp`.

This cheatcode is particularly useful when using `--via-ir` compilation with `vm.warp`. The Solidity compiler assumes `block.timestamp` is constant during a transaction, so with IR optimization enabled, multiple calls to `block.timestamp` may return the same cached value instead of the updated value. `vm.getBlockTimestamp()` avoids this optimization and always returns the current `block.timestamp`.

### Returns

| Parameter   | Type      | Description                        |
|-------------|-----------|-----------------------------------|
| `timestamp` | `uint256` | The current block timestamp       |

### Examples

```solidity [test/GetBlockTimestamp.t.sol]
function testGetBlockTimestamp() public {
    assertEq(vm.getBlockTimestamp(), 1, "timestamp should be 1");
    vm.warp(10);
    assertEq(vm.getBlockTimestamp(), 10, "warp failed");
}
```

### Gotchas

:::note
You only need to use this cheatcode when compiling with `--via-ir`. Without IR compilation, accessing `block.timestamp` directly works as expected.
:::

### Related Cheatcodes

* [`warp`](/reference/cheatcodes/warp) - Sets `block.timestamp`
* [`getBlockNumber`](/reference/cheatcodes/get-block-number) - Gets the current block number (avoids IR optimization issues)

### See Also

* [`skip`](/reference/forge-std/skip) - Skip forward in time
* [`rewind`](/reference/forge-std/rewind) - Rewind time
