Home / Admin / Create Additional Formats for the Date Field
Duplicate Snippet

Embed Snippet on Your Site

Create Additional Formats for the Date Field

Add custom date formats to the Date field in WPForms.

10+
Code Preview
php
<?php
/* 
Add additional formats for the Date field Date Picker. 
Original doc link: https://wpforms.com/developers/how-to-create-additional-formats-for-the-date-field/
For support, please visit: https://www.facebook.com/groups/wpformsvip
*/
 
function wpf_dev_date_field_formats( $formats ) {
  
    // Item key is JS date character - see https://flatpickr.js.org/formatting/
    // Item value is in PHP format - see http://php.net/manual/en/function.date.php
  
    // Adds new format Monday, 20th of December 2021
    $formats[ 'l, J \of F Y' ] = 'l, jS \of F Y';
	$formats[ 'l, J F Y' ] = 'l, jS F Y';
	$formats[ 'j-m-y' ] = 'j-m-y';
  
    return $formats;
}
  
add_filter( 'wpforms_datetime_date_formats', 'wpf_dev_date_field_formats', 10, 1 );

Comments

Add a Comment