Skip to content

Latest commit

 

History

History
166 lines (117 loc) · 7.8 KB

datetime.rst

File metadata and controls

166 lines (117 loc) · 7.8 KB

single: Forms; Fields; datetime

datetime Field Type

This field type allows the user to modify data that represents a specific date and time (e.g. 1984-06-05 12:15:30).

Can be rendered as a text input or select tags. The underlying format of the data can be a DateTime object, a string, a timestamp or an array.

Underlying Data Type can be DateTime, string, timestamp, or array (see the input option)
Rendered as single text box or three select fields
Options
Inherited options
Parent type form </reference/forms/types/form>
Class Symfony\\Component\\Form\\Extension\\Core\\Type\\DateTimeType

Field Options

date_widget

type: string default: choice

Defines the widget option for the date </reference/forms/types/date> type

time_widget

type: string default: choice

Defines the widget option for the time </reference/forms/types/time> type

widget

type: string default: null

Defines the widget option for both the date </reference/forms/types/date> type and time </reference/forms/types/time> type. This can be overridden with the date_widget and time_widget options.

input

type: string default: datetime

The format of the input data - i.e. the format that the date is stored on your underlying object. Valid values are:

  • string (e.g. 2011-06-05 12:15:00)
  • datetime (a DateTime object)
  • array (e.g. array(2011, 06, 05, 12, 15, 0))
  • timestamp (e.g. 1307276100)

The value that comes back from the form will also be normalized back into this format.

date_format

type: integer or string default: IntlDateFormatter::MEDIUM

Defines the format option that will be passed down to the date field. See the date type's format option <reference-forms-type-date-format> for more details.

format

type: string default: Symfony\Component\Form\Extension\Core\Type\DateTimeType::HTML5_FORMAT

If the widget option is set to single_text, this option specifies the the format of the input, i.e. how Symfony will interpret the given input as a datetime string. It defaults to the RFC 3339 format which is used by the HTML5 datetime field. Keeping the default value will cause the field to be rendered as an input field with type="datetime".

Inherited options

These options inherit from the form </reference/forms/types/form> type:

Field Variables

Variable Type Usage
widget mixed The value of the widget option.
type string Only present when widget is single_text and HTML5 is activated, contains the input type to use (datetime, date or time).