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

# Custom Datetime Format

> Customize the datetime format injected into the agent's system context.

```python datetime_format.py theme={null}
"""
Custom Datetime Format
======================

Customize the datetime format injected into the agent's system context.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIResponses

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
    model=OpenAIResponses(id="gpt-5-mini"),
    add_datetime_to_context=True,
    datetime_format="%Y-%m-%dT%H:%M:%SZ",  # ISO 8601 format in UTC (e.g., 2026-03-09T14:30:00Z)
    timezone_identifier="US/Eastern",
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("What is the current time and timezone?", stream=True)
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `datetime_format.py`, then run:

    ```bash theme={null}
    python datetime_format.py
    ```
  </Step>
</Steps>

Full source: [cookbook/02\_agents/03\_context\_management/datetime\_format.py](https://github.com/agno-agi/agno/blob/main/cookbook/02_agents/03_context_management/datetime_format.py)
