datasample

Display a date & time picker.

Thank you to @ardalann for creating the Date option 🙂

Option Details & Parameters

Type: date

Returns: string

Can be placed in: Admin Panels , Admin Tabs , Meta Boxes , Theme Customizer

Parameter Type Description
name string The name of the option, for display purposes only.
id string A unique ID for this option. This ID will be used to get the value for this option.
desc string The description to display together with this option.
default string (Optional) The default date to use. Defaults to blank. The format of the value is Y-m-d for the date, H:i for the time, and Y-m-d H:i for both date & time.
date boolean (Optional) If true, date selection is enabled. Defaults to true
time boolean (Optional) If true, time selection is enabled. Defaults to false

Returned Values

A string of the date, time or datetime. Below is the date format of the returned string:

  • Date only: Y-m-d
  • Time only: H:i
  • Date & time: Y-m-d H:i

CAUTION: When you try to pull the value from the settings, some servers may give you an Epoch instead of the specified returned values. In this case, you will need to convert it on the fly by using PHP’s date function.

Examples

Creating a date option:

$panel->createOption( array(
'name' => 'My Date Option',
'id' => 'my_date_option',
'type' => 'date',
'desc' => 'Choose a date',
'default' => '2010-12-20',
) );