Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-07-2002, 03:27 PM
tHE DSS's Avatar
tHE DSS tHE DSS is offline
 
Join Date: Jun 2002
Location: UK
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Handy Time Pieces

Place these in your 'functions.php' script if you wish.

Basically, this will give you some very handy timestamps, relative to the current viewer.... espeically good for statistics, relative to the current users time/date.

PHP Code:
// Get datelines, relative to user
// ********
// user local time
$user_time = mktime(date("H"),date("i"),date("s") + ($bbuserinfo[timezoneoffset] * 3600), date("m"), date("d"), date("Y"));
// today (start of day) dateline, relative to user
$ut_sod = (($user_time - (date("H", $user_time) * 3600)) - (date("i", $user_time) * 60)) - date("s", $user_time);
// this month (start of month) dateline, relative to user
$ut_som = mktime(0,0,0, date("m", $user_time), 1, date("Y", $user_time));
// this year (start of year) dateline, relative to user
$ut_soy = mktime(0,0,0,1,1, date("Y", $user_time));
// last year (start of last year) dateline, relative to user
$ut_soly = mktime(0,0,0,1,1, date("Y", $user_time)-1); 
For example :

PHP Code:
// Number Of Posts So Far Today
// ********
$getpoststoday = $DB_forum->query_first("SELECT count(*) AS count FROM post WHERE dateline>='$ut_sod'");
$postsToday = number_format($getpoststoday[count]);

// Number Of Posts Last Year
// ********
$getpostsLastYear = $DB_forum->query_first("SELECT count(*) AS count FROM post WHERE dateline<'$ut_soy' AND dateline>='$ut_soly'");
$postsLastYear = number_format($getpostsLastYear[count]); 
.... possibilities endless.
Reply With Quote
  #2  
Old 09-15-2002, 03:00 AM
JulianD's Avatar
JulianD JulianD is offline
 
Join Date: Jan 2002
Posts: 455
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks man... This could be usefull for some projects I'm working on!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:32 PM.


Powered by vBulletin® Version 3.9.0
Copyright ©2000 - 2017, vBulletin Solutions Inc.