Skip to content
Block Controls

Date Time Picker

Date Time Picker control allows users to select date and/or time values. One setting decides whether the control shows a calendar, a clock, or both.

Date Time Picker Control

Control Settings

The control has one setting, date_time_picker, a group of three buttons that defaults to date_time:

  • Date (date) - a calendar
  • Date & Time (date_time) - a calendar and a clock
  • Time (time) - a clock
Date, Date & Time and Time pickers

While the value is empty the control shows a button reading Select Date, Select Date and Time or Select Time. Once a value is set, the button prints it in the site's own date, time or date and time format. A Reset button appears under the picker and clears the value.

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

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?

Copyright © 2026 Lazy Blocks.