错误时间码codeigniter

I'm trying to calcute the time between now and a given time. But when I use timespan I get this error:

Fatal error: Call to undefined function timespan() in /Applications/MAMP/htdocs/VERSIE0.1/application/views/welcome_message.php on line 54 A PHP Error was encountered Severity: ErrorMessage: Call to undefined function timespan()Filename: views/welcome_message.phpLine Number: 54Backtrace:

<span class="time"><?php


                                 $post_date = $t['story_date'];
                                   $now = date('Y-m-d H:i:s');

                                   echo timespan($post_date, $now);

                                   ?> 
</span>

In order to use the timespan function you need to load its library, the helper.

Make sure you write:

$this->load->helper('date');

Try this

  • Load helper ( $this->load->helper('date'))

or You can use this

Right answer is to include the helper on your view file. Just load the helper

$this->load->helper('date');

in your view, not in controller.