Search code examples
datedrupaldrupal-7rssview

Drupal - date field language when used for RSS


I have a problem with the following scenario. I set up a node with a date field with type "Date (ISO format)". To display that nodes in a RSS feed, i created a view from content and format RSS-feed. In addition i set up a custom date format via "r" (RFC 2822) or (D, d M Y H:i:s O) in Drupal and used it for that field "field_time". That field is used as pubDate.

The date field creates instead of:

Wed, 01 Jul 2015 00:00:00 +0200

the "german" version.

Mi, 01 Jul 2015 00:00:00 +0200

If i do the same with for example the "created" date i get the correct english output.

I have allready tried to set the "field language" of that view to english. Also i tried to programmatically change the output in the rows tpl (overwhelming my php knowledge).

Its a very similar case like here.

Maybe someone can get me a hint to alter that field, change it in the rows template or something similar. Thanks in advance!


Solution

  • After some trail and error, i rewrote the output of my field "field_time" via the views templates at field level. I get the raw value from the field, converted it "again" in the RFC 2822 format and it sticks in english.

    $rawdate = $row->field_data_field_time_field_time_value;
    $unixdate = strtotime($rawdate);
    print date('r', $unixdate);
    

    I modified it after that a bit to get other nodes also in the feed which have only e.g. node_created via "rewrite if empty" in the views UI.

    if (isset($row->field_data_field_time_field_time_value)) {
      $rawdate = $row->field_data_field_time_field_time_value;
      $unixdate = strtotime($rawdate);
      print date('r', $unixdate);
    } else {
      print $output;
    }
    

    Im not sure, if that is very clean. Suggestions still welcome.