CodeIgniter Forums
Time difference craziness - 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: Time difference craziness (/showthread.php?tid=31694)



Time difference craziness - El Forum - 06-28-2010

[eluser]stuffradio[/eluser]
Some reason, when the time difference gets into the hours... it sometimes shows all the time differences as 354940.6 hours ago hours, etc. Here's the code I'm using:

Code:
$time = (time() - $rss->updated) / 60;
$hours = round($time / 60, 1);

$time is used for minutes, and $hours is the hours. $rss->updated is just a timestamp from the time it was inserted into the db. So why do I get these crazy hour differences sometimes?


Time difference craziness - El Forum - 06-29-2010

[eluser]LuckyFella73[/eluser]
The error must be anywhere else. I tried your
code and did some hardcoding (for emulation $rss->updated) and
I got a right value.

I would check if the timestamp from db is correct. All in all
it's strange anyway if your result is the same everytime you
render the page ...


Time difference craziness - El Forum - 06-29-2010

[eluser]stuffradio[/eluser]
It only happens sometimes. Like I said, the minutes time work perfectly all the time... it's only the hours one.