View Full Version : Code Help with Time (two days ago)
paul41598
10-22-2009, 05:07 PM
I'm looking for a little help with my code ...I think I have the theory of it wrong here...
Basically I want from the start of the day (two days ago) till the end of the day (two days ago)
$twodaysago = TIMENOW - (48 * 60 * 60);
$endoftwodaysago = TIMENOW - (24 * 60 * 60);
maybe its supposed to be similiar to this?
$twodaysago = TIMENOW - (48 * 60 * 60);
$endoftwodaysago = TIMENOW - (48 * 60 * 60) + something?;
paul41598
10-27-2009, 03:59 PM
anyone with some insight?
Lynne
10-27-2009, 05:14 PM
Your code it for 48 hours ago to 24 hours ago. There is no 'end of the day' for it, you are just doing it for a 24 hour period. Is that what you want? If not, then you will have to decide what exactly is the 'end of the day'.
paul41598
10-27-2009, 06:11 PM
I see..so I should have it right then eh? Its just weird, because the way my mod is coded (or cron job actually) is, it'll grab all threads whos expiration date was two days ago. So it would grab the 25th threads. However it also here and there grabs a few threads from the 26th, which doesnt make sense.
Lynne
10-27-2009, 06:28 PM
Without seeing your full code, I really can't comment on what is going on.
paul41598
10-27-2009, 06:49 PM
:)
$twodaysago = TIMENOW - (48 * 60 * 60);
$endofday = TIMENOW - (24 * 60 * 60);
$getthreadexpires = $vbulletin->db->query_read("
SELECT thread.* as thread, thread.threadid as tid, forum.forumid AS fid, forum.title AS ftitle, postlink.url as postlinkurl
FROM " . TABLE_PREFIX . "thread AS thread
LEFT JOIN " . TABLE_PREFIX . "postlink AS postlink ON (thread.firstpostid = postlink.postid)
LEFT JOIN " . TABLE_PREFIX . "forum AS forum ON (thread.forumid = forum.forumid)
WHERE forum.forumid IN($included_forums)
AND thread.thread_expiry <> 0
AND thread.thread_expiry >= $twodaysago
AND thread.thread_expiry <= $endofday
$adminwhere
");
//Check To See If Results
if ($vbulletin->db->num_rows($getthreadexpires)) {
while ($getthreadexpire = $vbulletin->db->fetch_array($getthreadexpires))
{
//Move Thread To Archive Forum
require_once(DIR . '/includes/functions_databuild.php');
$threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$threadman->set_existing($getthreadexpire);
$threadman->set('forumid', $vbulletin->options['threadexpiration_forumarchive']);
$threadman->save();
build_forum_counters($getthreadexpire['forumid']);
build_forum_counters($archive_forum);
}
Lynne
10-27-2009, 08:29 PM
Nothing really obvious stands out for me. However, there is no thread_expiry field in default vbulletin, so I can't really say whether anything to do with that field is correct.
paul41598
10-28-2009, 09:52 AM
Well..no the codebase works fine. I just wasn't sure about the whole $twodaysago and $endofday variables. I was trying to pull threads that had an expiration starting with two days ago, and ending that same day. So to me it would seem right, 48 hours ago and then 24 hours ago?
Its just weird that it pulls the 48 hour ago threads, but some 24 hour ago ones...when really I just wanted the 48 hour ago ones. Its confusing I guess
ZeepySea
10-29-2009, 03:14 AM
Try using just the < $endofday instead of <= $endofday
This way anything that equals 24 hours ago is ingored, but anything more than 24 hours ago is added.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.