我想将日期格式更改为d-m-y
表示日-月-年格式。我已添加
\'date_format\' => __( \'d-m-Y\', \'cmb2\' )
但不起作用。现在是年月日。实际上,我想改变日期格式,比如从年月日到年月日。
以下是代码:
add_filter( \'cmb_meta_boxes\', \'cmb_sample_metaboxes\' );
function cmb_sample_metaboxes( array $meta_boxes ) {
$prefix = \'_single_\';
$meta_boxes[] = array(
\'id\' => \'coupons_metabox\',
\'title\' => \'Coupon details\',
\'pages\' => array( \'coupons\', ), // Post type
\'context\' => \'normal\',
\'priority\' => \'high\',
\'show_names\' => true, // Show field names on the left
\'fields\' => array(
array( // Text Input
\'name\' => \'The date the coupon expires\', // <label>
\'desc\' => \'The expiration date of the coupon. Leave if empty if the coupon doesn\\\'t have an expiration date.\', // description
\'id\' => $prefix . \'date\', // field id and name
\'type\' => \'text_date_timestamp\', // type of field,
),
)
);
// Add other metaboxes as needed
return $meta_boxes;
}
add_action( \'init\', \'cmb_initialize_cmb_meta_boxes\', 9999 );
/**
* Initialize the metabox class.
*/
function cmb_initialize_cmb_meta_boxes() {
if ( ! class_exists( \'cmb_Meta_Box\' ) )
require_once \'init.php\';
}