Hi,

I have been trying to use date_convert to convert an ISO formatted date into a timestamp. The date_convert() function is called in my template.php as I want to apply the conversion at the themeing level. The raw value of the date field is "2011-06-10T21:30:00", which I assume is a standard ISO timestamp. However, date_convert() will only return NULL. I cannot understand why this is not working.

Could someone please assist me working out why?

Regards,

Ben

function intolatin_preprocess_views_view_fields__intolatin_events(&$vars) {
  $event_date = date_convert($vars['fields']['field_event_date_value']->raw, 'DATE_ISO', 'DATE_UNIX');
  if ($event_date == NULL) {
    drupal_set_message('Date could not be converted from ISO format.', 'error'); 
  }
  $vars['intolatin_event_date'] = '[' . $event_date . ']';
  dsm($vars);
}

Comments

damienmckenna’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

We're sorry but the D6 release of Date module is no longer being supported. You are encouraged to update to Drupal 7 or 8, or direct questions to Drupal Answers.