View source
<?php
class views_handler_field_profile_date extends views_handler_field_date {
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
unset($form['date_format']['#options']['time ago']);
}
function render($value) {
if (!$value->{$this->field_alias}) {
return;
}
$value = unserialize($value->{$this->field_alias});
$format = $this->options['date_format'];
switch ($format) {
case 'custom':
$format = $this->options['custom_date_format'];
break;
case 'small':
$format = variable_get('date_format_short', 'm/d/Y - H:i');
break;
case 'medium':
$format = variable_get('date_format_medium', 'D, m/d/Y - H:i');
break;
case 'large':
$format = variable_get('date_format_long', 'l, F j, Y - H:i');
break;
}
$date = gmmktime(0, 0, 0, $value['month'], $value['day'], 1970);
$replace = array(
'd' => sprintf('%02d', $value['day']),
'D' => NULL,
'l' => NULL,
'N' => NULL,
'S' => date('S', $date),
'w' => NULL,
'j' => $value['day'],
'F' => date('F', $date),
'm' => sprintf('%02d', $value['month']),
'M' => date('M', $date),
'n' => date('n', $date),
'Y' => $value['year'],
'y' => substr($value['year'], 2, 2),
'a' => NULL,
'A' => NULL,
'g' => NULL,
'G' => NULL,
'h' => NULL,
'H' => NULL,
'i' => NULL,
's' => NULL,
':' => NULL,
'T' => NULL,
' - ' => NULL,
':' => NULL,
);
return strtr($format, $replace);
}
}