vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Last 24 hours (https://vborg.vbsupport.ru/showthread.php?t=12059)

Sarge 03-22-2001 05:02 PM

I am installing the hack for

Yesterdays Top Posters
And I want to make sure I got something correct

Is below the correct time to display for the last 24 hours?

Did I get the time right?

Sarge

$curTime = localtime();
$uts = time() - ($curTime[2]*3600 + $curTime[1]*60 + $curTime[0]);
$lts = $uts - (86401); // 3600 * 24 + 1 (to be completely honest about "yesterday")
unset($curTime);

03-22-2001 07:35 PM

Considering I wrote that little piece of an algorithm you posted, in a way yes. That will calculate timestamps for the previous day, but don't confuse that with the last 24 hours. The last 24 hours would simple be the current timestamp - 86401.

What you have pasted will generate two timestamps: $lts (lower timestamp) will be equal to 00:00:00 the previous day, and $uts (upper timestamp) equal to 23:59:59 the previous day.

These timestamps can be used in a MySQL SELECT statement for comparrison with the dateline member or such things as posts, threads, polls.

03-22-2001 08:03 PM

It's more accurate to use mktime

$24hrsback = mktime (date("H")-24, date("i"), date("s"), date("m"), date("d"), date("Y"));
$now = time();

03-23-2001 01:31 AM

How is it more accurate? The current timestamp is the current timestamp.

Personally I don't like making tons of function calls when none are needed. Inside your call to mktime() you are calling date 6 times. Sure with today's processors the overhead of a function call is not much, but then lets add in the fact that PHP isn't compiled code... I haven't looked at the source yet, but I bet every call to a function creates a new local scope for the function in addition to any memory used inside the date function. It also uses formatted strings. All that will add up to more then the simple mathmatical operations on array elements.

I'm not trying to start a coding debate. The simple point is, run my code 1e9 times and run code with extra function calls and I don't think you can argue which will be faster. I don't like wasteing CPU cycles or memory where I don't have to.

03-23-2001 10:31 AM

What have i to do, if I want to install this hack?

Is there a hack to show yesterday new posts, threads an new members? Hope someone could help me :)

Have a nice day
Tommy


All times are GMT. The time now is 12:37 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.01155 seconds
  • Memory Usage 1,723KB
  • 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)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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