PHPBB $userdata['user_lastvisit'] trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
The Monkey
Forum Contributor
Posts: 168
Joined: Tue Mar 09, 2004 9:05 am
Location: Arkansas, USA

PHPBB $userdata['user_lastvisit'] trouble

Post by The Monkey »

Hello again!

I'm trying to have some code displaying under the menu of my regular site if the user is logged into my forums.

Using a tutorial by this guy, it's gone great so far... but after scouring the phpbb code multiple times in a ton of different pages, I have no clue how to turn the unintelligable numbers of user_lastvisit in the mysql phpbb_users table into something like "Wed March 10..."

My code:

Code: Select all

<?php
include('data/global/config.php');
define('IN_PHPBB', true);
$site_root_path = '/home/yolegoma/public_html/'; //<-- Modify
 $phpbb_root_path2 = '/themonkey/'; //<-- Modify
$phpbb_root_path = $site_root_path . $phpbb_root_path2;
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.php');

$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
$loggedin = $userdata['session_logged_in'];
$username = $userdata['username'];


// Jump down to troublesome code

echo 'Welcome, ' .$username. '!';
echo '<br />';

// This is the code we are looking at

// It comes out as wierd numbers such as 1078949351

echo 'You last visited ' .$userdata['user_lastvisit']. '.';
echo '<br />';
$authorized = '<a href="admin.php">Admin Page</a>';
	if($username == "myname") {
echo $authorized;
}
if($username == "myfriendsname") {
echo $authorized;
}

?>
I guess what I'm asking is how do I turn $userdata['user_lastvisit'] into something intelligable?

1078949351 into Wed March 10 blah blah.

If this has been asked before, I apologize. I spent an hour looking through the phpbb code, google, and these forums before asking!

- The Monkey
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

echo 'You last visited ' .date('D F d', $userdata['user_lastvisit']). '.';

See http://php.net/date for more date() options.
The Monkey
Forum Contributor
Posts: 168
Joined: Tue Mar 09, 2004 9:05 am
Location: Arkansas, USA

Post by The Monkey »

D'oh! Why didn't I think of php.net/date? :D

Thanks mark!
Post Reply