Jump to content

time format


zero061099

Recommended Posts

Ok partially un related but to describe what im tryin to do...here it goes. I have a vbulletin forum. I got this mod that will show the latest X threads in a table at the top of my forum. This is ajax based and updates or auto refreshes everytime someone responds. Of course it shows the time and date of that last reply like this

 

Last reply: 3-28, 8:22pm

 

So I wanted to change it to say like this....

 

Last reply: 2 minutes ago.  (without the date)

 

Of course I set the time frame for this for 60 minutes. SO after the 60 minutes it will look like this....

 

Last reply: 3-28, 61 minutes ago

 

SO a buddy helped me change it with this code

//number of minutes between now and last post
$time_difference = (time() - $gthread[lastpost]) / 60;

if( $time_difference < 60 )
{
    $gnptime = $time_difference .' minutes ago';
}
else
{
    $gnptime = vbdate('j-n, g:i', $gthread[lastpost]);
}   

 

from this

 

last reply: 3-28, 8:23pm

 

TO

 

last reply: 2.5454841 minutes ago

 

My question is how to get rid of the .5454841 ago and just have it say

 

last reply: 2 minutes ago?

 

Thanks for any help!

 

BTW: I asked him about that but thats all he knows.

Link to comment
https://forums.phpfreaks.com/topic/151564-time-format/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.