CodeIgniter Forums

Full Version: How to get time difference? [SOLVED]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]aryan_[/eluser]
I have two timestamp. I want to get the difference in hours(i.e. XX hours ago). How do I do this with either codeigniter or native php?

Thanks

El Forum

[eluser]vitoco[/eluser]
Code:
// timestamps
$t1 = 1000 ;
$t2 = 500 ;
// GET DIFF BETWEEN THE TWO TIMESTAMPS
$diff        = $t2 -$t1 ;
// CHANGE IT TO HOURS
$num_hours    = floor( $diff / ( 60*60 ) ) ;

El Forum

[eluser]aryan_[/eluser]
I also did the same, and it's working fine. It was so simple.

Thanks!

El Forum

[eluser]vitoco[/eluser]
please add [SOLVED] to the title, it saves time when you scan the forums