Skip to content

date

A control that can display and specify a formatted date, with or without time.

Properties

Name Type Default Description
date(★) dynamic(datetime)

The date that this control represents and can modify. It is typically bound to a datetime object.

with_time bool False

Whether or not to show the time part of the date.

format str

The format to apply to the value. See below.

editable dynamic(bool) True

Shows the date as a formatted string if not editable.

on_change Callback

The name of a function that is triggered when the value is updated.
The parameters of that function are all optional:

  • state (State): the state instance.
  • var_name (str): the variable name.
  • value (Any): the new value.

propagate bool App config

Allows the control's main value to be automatically propagated.
The default value is defined at the application configuration level.
If True, any change to the control's value is immediately reflected in the bound application variable.

(★)date is the default property for this visual element.

Styling

All the date controls are generated with the "taipy-date" CSS class. You can use this class name to select the date selectors on your page and apply style.

Stylekit support

The Stylekit provides a specific class that you can use to style date selectors:

  • fullwidth
    If a date selector uses the fullwidth class, then it uses the whole available horizontal space.

Usage

Using the full date and time

Assuming a variable dt contains a Python datetime object, you can create a date selector that represents it:

Page content

<|{dt}|date|>
<taipy:date>{dt}</taipy:date>

Using only the date

If you don't need to use the date, you can do so:

Page content

<|{dt}|date|not with_time|>
<taipy:date with_time="false">{dt}</taipy:date>