> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tenderly.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Working with timestamps on Virtual Environments

> Learn how you can access the correct timestamp and advance time on Virtual Environments

For certain types of tests it's useful to skip through time. This is possible by relying on 2 Admin RPC methods available on Virtual Environments: **[`evm_setNextBlockTimestamp`](/virtual-environments/admin-rpc/#evm_setnextblocktimestamp)** and **[`evm_setNextBlockTimestamp`](/virtual-environments/admin-rpc/#evm_setnextblocktimestamp)**.

## Getting the correct time

During execution of a transaction or `eth_call` accesses `block.timestamp` within a contract, the value will depend on whether the target block (`latest` or `pending`) block:

* For **`pending` block**: `block.timestamp == time.now() + adjustment_offset`. This represents the current time adjusted by the time-adjustment methods.
* For **`latest` block**: `block.timestamp == latest_block.timestamp`. This is the timestamp of the most recently mined block.

The `adjustment_offset` comes from time-adjustment methods:

1. [`evm_setNextBlockTimestamp`](/virtual-environments/admin-rpc/#evm_setnextblocktimestamp):
   Skips time to the timestamp for the next block: `adjustment_offset = timestamp - time.now()`.

2. [`evm_increaseTime`](/virtual-environments/admin-rpc/#evm_increasetime):
   Advances time by a relative amount.
   `adjustment_offset += increase_value`

## Examples

### Increase time by an offset

```bash showLineNumbers theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
VIRTUAL_TESTNET_RPC=https://YOUR-RPC-URL-HERE
curl -s -X POST \
  -H "Content-Type: application/json" \
  --data '{
    "jsonrpc": "2.0",
    "method": "evm_increaseTime",
    "params": ["0xe10"],
    "id": 2
  }' "$VIRTUAL_TESTNET_RPC"
```

### Set timestamp for pending block

```bash showLineNumbers theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
VIRTUAL_TESTNET_RPC=https://YOUR-RPC-URL-HERE

# Get the current date in Unix timestamp format
current_date=$(date +%s)

# Use evm_setTime to set the block time to today (current timestamp)
curl -s -X POST \
  -H "Content-Type: application/json" \
  --data '{
    "jsonrpc": "2.0",
    "method": "evm_setNextBlockTimestamp",
    "params": ["'"$current_date"'"],
    "id": 3
  }' "$VIRTUAL_TESTNET_RPC"
```
