I used this code, instead, as strtotime can throw errors sometimes. The only hitch is that the Date field must be datestamp. This also supports endDates, handily enough.
if(isset($fields['startDate'])) {
if (is_array($fields['startDate'])) {
// Processing for datestamp fields from the Date module
$date_tmp = array_shift($fields['startDate']);
$fields['startDate'] = $date_tmp['value'];
if (isset($date_tmp['value2'])) {
$fields['endDate'] = $date_tmp['value2'];
}
else {
$fields['endDate'] = $fields['startDate'];
}
}
$fields['startDate'] = format_date($fields['startDate'], 'custom', 'Y,m,d');
}
Comments
Comment #1
polI tried with this bit of code, and it works pretty good, so you can use any time format.
Comment #2
chromix commentedI used this code, instead, as strtotime can throw errors sometimes. The only hitch is that the Date field must be datestamp. This also supports endDates, handily enough.
Comment #3
polThe first parameter of
format_date()must be a timestamp and$fields['startDate']is not always a timestamp, that's why I usestrtotime().I made some improvements to the module, I'll post them tonight.
Comment #4
pol