CodeIgniter Forums
timespan help - 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 help (/showthread.php?tid=42804)



timespan help - El Forum - 06-20-2011

[eluser]Wonder Woman[/eluser]
Hi,

I want to convert a timestamp which I have saved in my db to say X days ago, or X hours ago, a bit like how its done on facebook.

I have came across timespan but its displaying the wrong time...my database seems to store timestamps like 0000-00-00 00:00:00 whereas I think it needs to be like this instead 123456789

I am using timespan like this...

Code:
$post_date = $record['created'];
$now = time();
echo timespan($post_date, $now);

If you can help me fix this, that would be great.

Thanks


timespan help - El Forum - 06-20-2011

[eluser]Atharva[/eluser]
Code:
$post_date = strtotime($record['created']);
$now = time();
echo timespan($post_date, $now);



timespan help - El Forum - 06-20-2011

[eluser]Wonder Woman[/eluser]
Spot on - thanks Big Grin