View Full Version : time format?
zero5854
03-21-2009, 02:45 AM
Ok so with help from staff I was able to change my forums last post time to say "X minutes ago"
So now I want to change this in a older mod I have. The code is like this....
$gnptime = vbdate('H:i', $gthread[lastpost]);What would I change the 'H:i' to get it the same detailed time like X minutes ago?
Lynne
03-21-2009, 04:02 PM
Try something like:
$gnptime = vbdate($vbulletin->options['timeformat'], $gthread[lastpost], true);
zero5854
03-21-2009, 11:12 PM
so I replace 'timeformat' with what???
BTW thanks for answering !
TigerC10
03-21-2009, 11:33 PM
You don't replace it with anything. The variable being used $vbulletin->options['timeformat'] will be in your vBulletin date/time format options.
If you want to learn about the "H:i" modifier characters, view this page:
http://us2.php.net/manual/en/function.date.php
Have you tried
$gnptime = vbdate('i', $gthread[lastpost]);
If you want to do it in a more complicated way it would be:
$majormin = date('H', $gthread[lastpost]) * 60;
$minormin = date('i', $gthread[lastpost]);
$gnptime = $majormin+$minormin;
zero5854
03-22-2009, 12:01 AM
thanks that was what I meant to ask sorry I wasnt more clear.
What im trying to achieve is X minutes ago
Lynne
03-22-2009, 12:03 AM
so I replace 'timeformat' with what???
BTW thanks for answering !
I gave you a line to try in place of what you were trying.
zero5854
03-22-2009, 12:12 AM
I know and I did thank you but that didnt do anything.... See I used 'H:i A' BUT It still shows army time. I tried the other guys code and it shows the wrong time.
heres mine.....
21-03, 21:08 PM
I want it to look like
21-3, 9:08 PM
Lastly I really wanted it to look say it was posted 1 minute ago...
21-3, 1 Minute ago
IS this possible?
TigerC10
03-22-2009, 02:11 AM
That's why I gave you the php manual page, it tells you how to make your own date format string. But since you're too lazy, here...
For "21-3, 9:08 PM" Use:
$gnptime = vbdate('j-n, g:i', $gthread[lastpost]);
For the "1 Minute ago" thing, normally date's aren't shown - that's generally only if the post was made within an hour in the past. You'll have to do some math if you want that to display properly.
//number of minutes between now and last post
$time_difference = (time() - $gthread[lastpost]) / 60;
if( $time_difference < 60 )
{
$gnptime = vbdate('j-n', $gthread[lastpost]);
$gnptime .= ', '. $time_difference .' minutes ago';
}
else
{
$gnptime = vbdate('j-n, g:i', $gthread[lastpost]);
}
zero5854
03-22-2009, 03:07 AM
sorry I am lazy I thought maybe someone knew off the top of their head as ive seen this on many forums. THanks for your hard work. Lately I have been lazy, working alot! thanks!
--------------- Added 1237755290 at 1237755290 ---------------
OK I see what u mean by the date thing so I guess I will remove that. Now I tried some of the code without the date thing but that only will show just a comma now? Any idea on that? I have tried the coding found at php website with no good results.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.