vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   HELP!!! I need to find the timestamp ranges for the last 7 days.. (https://vborg.vbsupport.ru/showthread.php?t=70125)

Michael Morris 10-03-2004 03:14 AM

HELP!!! I need to find the timestamp ranges for the last 7 days..
 
Hi.

I'm trying to write a script that blocks news into daily digests. Since vbulletin uses a timestamp instead of a date field I need to find a way to query for the last seven days, one at a time (since doing them together confuses the sorting no matter how I try). I've been searching through the code to try to find such a function, no luck. I'm getting angry because I wouldn't have to do all this work if vbulletin would either use a proper date field MySQL can manipulate or at least include on in addition to the timestamp...

Rephrase -- I need to find out the time range for today, then yesterday, then the day before yesterday and so on back 7 days. Each time will be a query.

Velocd 10-03-2004 03:33 AM

Timestamps are in seconds. They're much more convenient to use, from my experience, then the inflexible SQL date format. Plus, they contain time, not merely the date.

So if you want days, take (60 x 60) x 24, giving you 86,400. 86,400 x 2, 3, ... 7 will give you those timestamps for that duration of days.

PHP Code:

// Place ranges into an array.

for ($i 1$i <= 7$i++)
{
    
$array[] = TIMENOW - ($i 86400);


Another method to get the timestamp (relative to today) without math is using strtotime():

PHP Code:

$seven_days_ago strtotime('7 days ago'); 


Michael Morris 10-03-2004 04:02 AM

Quote:

Originally Posted by Velocd
Timestamps are in seconds. They're much more convenient to use, from my experience, then the inflexible SQL date format. Plus, they contain time, not merely the date.

So if you want days, take (60 x 60) x 24, giving you 86,400. 86,400 x 2, 3, ... 7 will give you those timestamps for that duration of days.

PHP Code:

// Place ranges into an array.

for ($i 1$i <= 7$i++)
{
    
$array[] = TIMENOW - ($i 86400);


Another method to get the timestamp (relative to today) without math is using strtotime():

PHP Code:

$seven_days_ago strtotime('7 days ago'); 


That can't work because days start and end at midnight, and the functions you cite calculate going back from the current time.

I found something that I *think* will work, the MySQL UNIX_TIMESTAMP function...

Treasure Quest 01-26-2005 05:36 PM

Hi,
Sorry to but in but could someone tell me or send me a link to how I can display the timestamp "Yesterday" "Today" in bold?
I think they would stand out better in bold.

Thanks,

Greg


All times are GMT. The time now is 05:54 AM.

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.01077 seconds
  • Memory Usage 1,728KB
  • 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
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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