How to create a new block programmatically? I need to programmatically create a new block. The block must show 3 last news (site content): title as a link + date of publication (format dd-mm-yyyy).

Any suggestions?
The info hook defines your block in the system: 

function my_module_block_info() {    
  $blocks['your_block'] = array(
    // info: The name of the block.
    'info' =&gt; t('Your Block Name'),
  );

  return $blocks;
}


and the view hook creates the output (html) for your block:

function my_module_block_view($delta = '') {
  // The $delta parameter tells us which block is being requested.
  switch ($delta) {
    case 'your_block':
      // Create your block content here
      $block['subject'] = t('My last 3 news');

    $query = new EntityFieldQuery();
    //change news by the name of your content type
    $entities = $query-&gt;entityCondition('entity_type', 'node')
    -&gt;entityCondition('bundle', 'news')
    -&gt;propertyOrderBy("created", "DESC")
    -&gt;range(0, 3)
    -&gt;execute();

    $block['content'] = '';

    foreach($entities['node'] as $obj) {
      $node = node_load($obj-&gt;nid);
          $block['content'] .= l($node-&gt;title, "node/" . $node-&gt;nid) . ' - ' . date('d-m-Y', $node-&gt;created) . '&lt;br&gt;';
    }

     break;
   }

  return $block;
}


Remember assign a region to your block in YOUR_SITE/admin/content/blocks

Output:



References:

How do I create a static block programmatically?