MyBB Community Forums

Full Version: Change years
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi my friends!

I close my forum at 2012. Now I wanna reopen it but I wanna change all posts data from year 2011 to 2013 and 2012 to 2014.
How can i do that  Huh

cheers  Heart
Hi, I'm just not sure but personally, but if someone out there has a clear cut solution, I would be amazed to know because like I said, things can get messy really quick, good luck, I hope someone can give you a better answer.
If your database is large you'd have to use pagination to do this, but here is a script you can use.

define("IN_MYBB", 1);
define("NO_ONLINE", 1);
require_once "global.php";
$query = $db->simple_select("posts", "pid, dateline");
// First posts.
while($post = $db->fetch_array($query))
$updated_post['dateline'] = $post['dateline'] + 63072000;
$pid = $post['pid'];
$db->update_query("posts", $updated_post, "pid=$pid");
// Now threads
$query = $db->simple_select("threads", "tid, dateline, lastpost");
while($thread = $db->fetch_array($query))
$updated_thread['dateline'] = $thread['dateline'] + 63072000;
$updated_thread['lastpost'] = $thread['lastpost'] + 63072000;
$tid = $thread['tid'];
$db->update_query("threads", $updated_thread, "tid=$tid");
echo "Times updated.<br /> <a href=\"index.php\">Click Here to return to the forum</a>";

1) Upload a file with that code in it into your forums directory.
2) Point your browser to that file and it will update everything.
3) Delete the file.
@dragonexpert - wow it works, I dont know how... but I dont care!
Big thanx