vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   time difference between forum database and time() (https://vborg.vbsupport.ru/showthread.php?t=125352)

bosal 08-30-2006 09:18 PM

time difference between forum database and time()
 
Hello.

I want to make simple script in PHP, that will check, if latest thread in specified board is older than 7 days, and if so, random thread from different board will be moved to that board. I just have small problem about it, because i don't what time difference is between time() and dateline in database.

Here's what i'm doing:
PHP Code:

     $tsql mysql_query("SELECT threadid,title,dateline FROM thread WHERE forumid=$poll_forum_id and open=1 ORDER BY dateline DESC LIMIT 1");
     
$temat=mysql_fetch_array($tsql);
     
     
$timediff=2*60*60-7// it looks like around 2 hours, but not exactly, i have no idea what this value should be.
     
     
if ($temat['dateline']+$timediff<time()-7*24*60*60// is thread older than 7 days
     
{
        
$tsql mysql_query("SELECT threadid FROM thread WHERE forumid=158 and open=1 ORDER BY rand() LIMIT 1");
        if (
mysql_num_rows($tsql)>0)
        {
           
$th=mysql_fetch_array($tsql);
           
mysql_query('UPDATE `thread` SET (
              forumid='
.$poll_forum_id.',
              dateline='
.now()+$timediff .') where threadid='.$th['threadid']);
        }
     } 

For me this difference looks like something around 2 hours, but not exactly, few secounds less. How can i get this difference and be sure, than when time will be changed from summer to winter it will still work fine?


All times are GMT. The time now is 03:26 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.00906 seconds
  • Memory Usage 1,718KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)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