CodeIgniter Forums
Timespan on single table column - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Timespan on single table column (/showthread.php?tid=44288)



Timespan on single table column - El Forum - 08-10-2011

[eluser]Unknown[/eluser]
Hi all,
New to code igniter but liking it so far. Quick problem, hopefully.

I'm pulling data from a database, returning a time in utc format. This it then being put into a table using the table library. So far so good.

What I want to do is use timespan to format the date difference correctly, eg.
$this->table->function = 'timespan';

However, I only want this to happen on one column - is this possible?
Thanks.


Timespan on single table column - El Forum - 08-10-2011

[eluser]jmadsen[/eluser]
you will need to either:

1) format it in your sql query beforehand

2) in your controller, foreach over your result set and format that column

i don't believe you can do it like you are trying, but I don't use the table lib that often


Timespan on single table column - El Forum - 08-10-2011

[eluser]Unknown[/eluser]
Ok, thanks. I think formatting in mysql might be more trouble than it's worth so will try the 2nd suggestion.
Dazza