How to change bean's block view mode programmatically? I have created a block entity using bean module.

It has three image fields. Image1, Image2 and Image3.

I want to show only one image depending upon current time. I have three time values.
For this I have created 3 view modes each for one time value.

Now I'm stuck that how will change the view mode based on time value programmatically.

I have used the following code.

function glue_site_block_view_alter(&amp;$data, $block) {
  if ($timevalue1 == $value1) {
    $data['content']['bean']['block_delta']['#view_mode'] = 'view_mode1'
}
You can use hook_entity_view_mode_alter()

function MYMODULE_entity_view_mode_alter(&amp;$view_mode, $context) {  
    if ($timevalue1 == $value1) {  
      $view_mode = 'view_mode1';  
    } elseif {  
      .......  
    }  
}