Hi Richard
We seem to have identified what’s causing the problem. It seems that the misbehaviour is in one of the EE core files.
We’re triggering the error based on the categories posted in one of our hooks and are showing it by using the new_entry_form function:
$EE->new_entry_form('preview', '<ul><li>'.implode('</li><li>',array_filter($errors)).'</li></ul>');
$EXT->end_script = TRUE;
At around the line 2876 in cp.publish.php, the following code handles EE date fields:
if ($dtwhich != 'preview' OR $submission_error != '')
{
$localize = TRUE;
print_r($field_data);
if ($field_data != '' AND isset($result))
{
if (isset($result->row['field_dt_'.$row['field_id']]) AND $result->row['field_dt_'.$row['field_id']] != '')
{
$field_data = $LOC->offset_entry_dst($field_data, $dst_enabled);
$field_data = $LOC->simpl_offset($field_data, $result->row['field_dt_'.$row['field_id']]);
$localize = FALSE;
}
}
if ($field_data != '')
$custom_date = $LOC->set_human_time($field_data, $localize);
$cal_date = ($LOC->set_localized_time($field_data) * 1000);
}
else
{
$custom_date = $_POST[$date_field];
$cal_date = ($custom_date != '') ? ($LOC->set_localized_time($LOC->convert_human_date_to_gmt($custom_date)) * 1000) : ($LOC->set_localized_time() * 1000);
}
Now, the date from your custom date field is passed along to this functon corretly, it’s correclty in the $_POST var and also in this function, the troublemaker now are the following lines:
if ($field_data != '')
$custom_date = $LOC->set_human_time($field_data, $localize);
$field_data contains the correnct date (something like 2008-10-23 05:19 PM for example), the function $LOC->set_human_time being called with the $field_data value for the date field however returns always 1970-01-01 03:33 AM which is also the value being shown in the date’s text field.
Seems that $custom_date is always 1970-01-01 03:33 AM in that case.
Changing those lines to
if ($field_data != '')
$custom_date = $field_data;
correctly renders the date in the date’s text field as now the value of $custom_date is the actual posted value.
However, we should definitely get a word from the core developers on this as it seems that the set_human_time function renders the wrong date? Are we missing something?