PDA

View Full Version : Entering timestamp into database.


Attilitus
08-13-2006, 02:04 AM
I would just like to know how to enter a timestamp into the database per user.

Just so I could do a function where the old timestamp was subtracted from the new timestamp to get a readout of "There has been x time since..."

Could anyone give me a little code snippet or at least tell me the function to do this?

Thanks!

AN-net
08-16-2006, 02:47 PM
what time do you want though? lastlogin, lastpost, etc.?

also do you just want to display it? if so, this would work:

$timediff = TIMENOW - $timefromdb;


if you want to save that difference to the database, specifically the user table, you would have to first add a new field via phpmyadmin or the similar from your site's control panel(not the vbulletin's admin control panel).

then you could update the database with this code:

$db->query_write("UPDATE " . TABLE_PREFIX . "user SET yournewfield=" . intval($timediff) . " WHERE userid=" . $vbulletin->userinfo['userid'] . "");