How to change the output field date in a view? I want to alter a field 'Date' in the view to display only year using 'hook_views_query_alter', so that I can display only Year in the date field.
I'm trying below code, which is not working. Can anybody help me?
I'm not sure about assigning new value to the field in the code.
function alb_jobs_views_query_alter(&amp;$view, &amp;$query) {
 
  if ($view-&gt;name == 'test-archive') {
  $query-&gt;where[0]['conditions'][0] == array('field'=&gt;&quot;field_data_field_issuu_date.field_issuu_date_value&quot;,&quot;value&quot;=&gt;'%YEAR(STR_TO_DATE(field_data_field_issuu_date.field_issuu_date_value,&quot;%Y&quot;))%',&quot;operator&quot;=&gt;&quot;LIKE&quot;);
 
  }
}

Here is my date field screenprint:
If you are asking for the how to get year from date and use the year in view query alter then 

You can use strtotime();

$year = date('Y', strtotime($field_data_field_issuu_date.field_issuu_date_value));


Another way in view you can use custom date format on display and show only year and use that value.(Depends on requirement)