I have difficulties with getting a render Date (ISO) field from code. The field has machine-name field_date
. By default, the Date field has three formatter: "long", "medium" and "small". The default formatter for node is set to "medium". (I've checked that, if the field is displayed in usual node's view, it's formatted as it should be)
Here's the code:
$node = node_load($nid);
$field_date = field_get_items('node', $node, 'field_date');
$render_field_date = field_view_value('node', $node, 'field_date', $field_date[0]);
But the output I get is in "long" variant. Drupal.org says that by default it uses "default_formatter" which is defined in date_field_formatter_info()
(having inspected the code, I figured out that that 'default_formatter' actually means 'long'). Well, I want it to be formatted in "medium" way. I write these lines:
$render_field_date = field_view_value('node', $node, 'field_date', $field_date[0], array('type' => 'medium') );
but it's still in its "long". What is wrong with the code?