user3071261
user3071261

Reputation: 386

Error timespan 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>

Upvotes: 0

Views: 744

Answers (3)

BGKND
BGKND

Reputation: 53

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.

Upvotes: 0

Muhammad Faran Ali
Muhammad Faran Ali

Reputation: 499

Try this

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

or You can use this

Upvotes: 4

Ofir Baruch
Ofir Baruch

Reputation: 10356

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

Make sure you write:

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

Upvotes: 3

Related Questions