I have assumed that the read state will never format the date so I decided to do it myself by modifying the read.php file under assets\grocery_crud\themes\datatables\views.
You just need to add the below code in the div that prints the values out, around line 34.
Before the change:
<div class='form-input-box' id="<?php echo $field->field_name; ?>_input_box"> <?php echo $input_fields[$field->field_name]->input?>
After the change:
<div class='form-input-box' id="<?php echo $field->field_name; ?>_input_box"> <?php $res = preg_match('/[0-9]{4}\-[0-9]{2}\-[0-9]{2}/',$input_fields[$field->field_name]->input,$var); if($res==1) { if(!preg_match('/0000/',$var[0])) { $ci = &get_instance(); $dt = new DateTime($var[0]); $output = $dt->format($ci->config->item('grocery_crud_default_date_format')); $res = preg_match('/[0-9]{4}\-[0-9]{2}\-[0-9]{2}\s[0-2][0-9]\:[0-6][0-9]/',$input_fields[$field->field_name]->input,$var); if($res==1) { $dt = new DateTime($var[0]); $output = $dt->format($ci->config->item('grocery_crud_default_datetime_format')); } echo $output; } else echo ""; } else echo $input_fields[$field->field_name]->input?>
Now you can test the date format in the read state... and make sure you have defined the format you want in the application/config/grocery_crud.php file, I used:
$config['grocery_crud_default_date_format'] = 'd M Y'; $config['grocery_crud_default_datetime_format'] = 'd M Y - H:i';
Cheers!