vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Time Since Forum Leaders Offline (https://vborg.vbsupport.ru/showthread.php?t=35764)

Robert9 03-06-2002 11:18 AM

yeah, one day iss great, havephun :)

Freddie Bingham 03-06-2002 04:10 PM

/me is confused about adding new fields since you can simply reference lastvisit to figure how long it has been since someone has been online. It will be exact if the person logged out and it will be TIMENOW - lastvisit - cookietimeout if they used cookies.

Neo 03-06-2002 05:10 PM

Thats true, but I wasnt thinking about that...I was just thinking about how it would look in my head if I was coding it without the use of vb.

Neo 03-14-2002 03:52 AM

OK... I will have something soon.

Boofo 12-08-2002 12:21 AM

How soon? :)

Logik 01-02-2003 02:21 AM

I wouldn't mind this hack either. ;)

Mystis 01-02-2003 06:55 AM

Deviantart inspired? :) This should be a piece of cake, I believe I've got a function sitting around to return a formatted difference between 2 times. I'll see if I can dig it up. Sorry if I'm stepping on your toes, Neo :)

Edit: just realized how old this thread is, but I'll still finish the hack anyway, could be useful to someone :)

Mystis 01-02-2003 07:24 AM

PHP Code:

function pluralize($word,$var){
    if(
$var!=1){
        
$word $word."s";
    }
    if(
$var>0){
        
$word $var." ".$word." ";
    }else{
        
$word "";
    }
    return 
$word;
}
function 
timediff($earlier,$later){
    
$secs $earlier $later
    
$string="";
    if(
$secs>=604800){
        
$weeks 0;
        while(
$secs>=604800){
            
$secs -= 604800;
            
$weeks++;
        }
        
$string .= pluralize("week",$weeks);
    }
    if(
$secs>=86400){
        
$days 0;
        while(
$secs>=86400){
            
$secs -= 86400;
            
$days++;
        }
        
$string .= pluralize("day",$days);
    }
    if(
$secs>=3600){
        
$hours 0;
        while(
$secs>=3600){
            
$secs -= 3600;
            
$hours++;
        }
        
$string .= pluralize("hour",$hours);
    }
    if(
$secs>=60){
        
$minutes 0;
        while(
$secs>=60){
            
$secs -= 60;
            
$minutes++;
        }
        
$string .= pluralize("minute",$minutes);
    }
    return 
$string;


There are the functions anyway, you would use like this:
PHP Code:

$variable timediff(time(),$userlastvisit); 

with $userlastvisit being the field 'lastvisit' pulled from the user table from the row of the corresponding member. Then, just add $variable in any of your templates and it will return a string something like "1 day 3 hours 12 minutes", or "2 weeks 8 hours 1 minute". Let me know where you would want this information displayed, and I'll write and release a full fledged hack for it.


All times are GMT. The time now is 01:01 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.01189 seconds
  • Memory Usage 1,742KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete