vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Design and Graphics Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=168)
-   -   time format? (https://vborg.vbsupport.ru/showthread.php?t=208971)

zero5854 03-21-2009 02:45 AM

time format?
 
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....

Code:

$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:

PHP Code:

$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
PHP Code:

$gnptime vbdate('i'$gthread[lastpost]); 



If you want to do it in a more complicated way it would be:
PHP Code:

$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

Quote:

Originally Posted by zero5854 (Post 1773755)
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:

PHP Code:

$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.

PHP Code:

//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 [DATE]1237755290[/DATE] at [TIME]1237755290[/TIME] ---------------

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.


All times are GMT. The time now is 02:33 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01914 seconds
  • Memory Usage 1,740KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (5)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete