View Categories

Field Type: Datetime

Table of Contents

A date and time picker for scheduling and time-based settings with optional time selection.

Example Usage #

sample-plugin.php
// With time picker
array(
	'id'          => 'maintenance_end',
	'title'       => 'Maintenance End Time',
	'desc'        => 'Select the date and time when maintenance should end',
	'type'        => 'datetime',
	'settings'    => array(
		'timePicker' => true,
	),
	'placeholder' => 'Select end date and time',
	'value'       => get_option( 'maintenance_end' ),
),


// Date picker only
array(
	'id'          => 'launch_date',
	'title'       => 'Launch Date',
	'desc'        => 'Select the product launch date',
	'type'        => 'datetime',
	'settings'    => array(
		'timePicker' => false,
	),
	'placeholder' => 'Select launch date',
	'value'       => get_option( 'launch_date' ),
),

Properties #

  • id (required) – Unique identifier for the field
  • title (required) – Label displayed above the field
  • desc (optional) – Help text shown below the field
  • type (required) – Must be 'datetime'
  • settings (optional) – Configuration object with timePicker boolean
  • placeholder (optional) – Placeholder text shown when no date is selected
  • value (optional) – Current date/time value in ISO format string

Notes #

By default, timePicker is true. The field returns dates in ISO 8601 format (e.g., 2024-12-25T14:30:00). For date-only fields, set timePicker to false.