Skip to content
Controls

Date Time Picker

Date Time Picker control allows users to select date and/or time values. The control provides three variants to match your needs.

Date Time Picker Control

Available Variants

Choose from three picker types:

  • Date picker
  • Time picker
  • Date + Time picker
Date time picker variants preview

The control saves date in YYYY-MM-DDTHH:ii:ss format regardless of the display format.

Control Settings

  • Variants - Choose between Date picker, Time picker or Date + Time picker

Usage Examples

PHP

PHP
<?php
$date = $attributes['control_name'];
 
// Date + Time format
echo '<p>' . date_i18n( 'F j, Y H:i', strtotime( $date ) ) . '</p>';
 
// Date only format
echo '<p>' . date_i18n( 'F j, Y', strtotime( $date ) ) . '</p>';
 
// Time only format
echo '<p>' . date_i18n( 'H:i', strtotime( $date ) ) . '</p>';

Handlebars

Handlebars
{{! Date + Time format }}
<p>
  {{date_i18n "F j, Y H:i" control_name}}
</p>
 
{{! Date only format }}
<p>
  {{date_i18n "F j, Y" control_name}}
</p>
 
{{! Time only format }}
<p>
  {{date_i18n "H:i" control_name}}
</p>

Post Meta

Post Meta
<?php
$date = get_lzb_meta( 'control_meta_name' );
 
// Date + Time format
echo '<p>' . date_i18n( 'F j, Y H:i', strtotime( $date ) ) . '</p>';
 
// Date only format
echo '<p>' . date_i18n( 'F j, Y', strtotime( $date ) ) . '</p>';
 
// Time only format
echo '<p>' . date_i18n( 'H:i', strtotime( $date ) ) . '</p>';

Common Format Patterns

FormatOutputDescription
F j, Y H:iMarch 1, 2024 13:45Full date and time
F j, YMarch 1, 2024Full date
m/d/Y03/01/2024Short date
H:i13:4524-hour time
g:i a1:45 pm12-hour time

Use WordPress date_i18n() function to ensure proper date localization in your output.

Was this article helpful?