Controls
Date Time Picker
Date Time Picker control is used to store a string with selected date and/or time for the block. Available variants of this control:
- Date picker
- Time picker
- Date + Time picker
The date string will be saved in the following format YYYY-MM-DDTHH:ii:ss
. See examples below to use this control.
Control Settings
- Variants – limit picker for one of these variants -
Date picker
,Time picker
orDate + Time picker
Usage
PHP
Date + Time:
<p>
<?php echo date_i18n( 'F j, Y H:i', strtotime( $attributes['control_name'] ) ); ?>
</p>
Date:
<p>
<?php echo date_i18n( 'F j, Y', strtotime( $attributes['control_name'] ) ); ?>
</p>
Time:
<p>
<?php echo date_i18n( 'H:i', strtotime( $attributes['control_name'] ) ); ?>
</p>
Handlebars
Date + Time:
<p>
{{date_i18n "F j, Y H:i" control_name}}
</p>
Date:
<p>
{{date_i18n "F j, Y" control_name}}
</p>
Time:
<p>
{{date_i18n "H:i" control_name}}
</p>
Post Meta
<?php
// date in this format: YYYY-MM-DDTHH:ii:ss
$date = get_lzb_meta( 'control_meta_name' );
// Date + Time:
echo date_i18n( 'F j, Y H:i', strtotime( $date ) );
// Date:
echo date_i18n( 'F j, Y', strtotime( $date ) );
// Time:
echo date_i18n( 'H:i', strtotime( $date ) );