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

# DateTime

> Create date and time selection components in Gradio

The DateTime component allows users to select dates and optionally times.

## Basic usage

```python theme={null}
import gradio as gr

def process_date(dt):
    return f"Selected: {dt}"

gr.Interface(
    fn=process_date,
    inputs=gr.DateTime(),
    outputs=gr.Textbox()
).launch()
```

## Constructor

<ParamField path="value" type="float | str | datetime | None" default="None">
  Default datetime value
</ParamField>

<ParamField path="include_time" type="bool" default="True">
  Whether to include time selection. If False, only date is selectable
</ParamField>

<ParamField path="type" type="Literal['timestamp', 'datetime', 'string']" default="'timestamp'">
  Return format:

  * `"timestamp"` - Unix timestamp (seconds since epoch)
  * `"datetime"` - Python datetime object
  * `"string"` - Formatted string
</ParamField>

<ParamField path="timezone" type="str | None" default="None">
  Timezone (e.g., "US/Pacific", "Europe/Paris"). If None, uses local timezone
</ParamField>

<ParamField path="label" type="str | None" default="None">
  Label displayed above component
</ParamField>

<ParamField path="interactive" type="bool | None" default="None">
  Whether datetime can be changed
</ParamField>

## Events

* **change** - Triggered when datetime changes
* **submit** - Triggered when datetime is submitted

## Examples

### Date only

```python theme={null}
import gradio as gr

gr.DateTime(
    include_time=False,
    label="Select a date"
)
```

### With timezone

```python theme={null}
import gradio as gr

gr.DateTime(
    include_time=True,
    timezone="US/Pacific",
    label="Pacific Time"
)
```

### Return as datetime object

```python theme={null}
import gradio as gr
from datetime import datetime

def format_date(dt):
    return dt.strftime("%A, %B %d, %Y at %I:%M %p")

gr.Interface(
    fn=format_date,
    inputs=gr.DateTime(type="datetime"),
    outputs=gr.Textbox()
).launch()
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.