Skip to main content

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.

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

Basic usage

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

value
float | str | datetime | None
default:"None"
Default datetime value
include_time
bool
default:"True"
Whether to include time selection. If False, only date is selectable
type
Literal['timestamp', 'datetime', 'string']
default:"'timestamp'"
Return format:
  • "timestamp" - Unix timestamp (seconds since epoch)
  • "datetime" - Python datetime object
  • "string" - Formatted string
timezone
str | None
default:"None"
Timezone (e.g., “US/Pacific”, “Europe/Paris”). If None, uses local timezone
label
str | None
default:"None"
Label displayed above component
interactive
bool | None
default:"None"
Whether datetime can be changed

Events

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

Examples

Date only

import gradio as gr

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

With timezone

import gradio as gr

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

Return as datetime object

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()

Build docs developers (and LLMs) love