1 (edited by Loa 2005-07-22 13:33)

Topic: Last visit

I have edited my member list so it show's last visit instead of the registrated date....

but I want the list to show how many days ago and not the day they where in last.. so how do that work in php??

I have "1122029865" for example on one member...

Fetched the code....

<td class="tcr"><?php echo format_time($user_data['last_visit'], true) ?></td>

so.. are there any possibility that the thing can show...
"Today"
"Yesterday"
"1 Day ago"
"2 Days ago... and so on.."

Cheers Carl

2

Re: Last visit

Well, you could do something like this (untested)

<?
$now = strtotime(date("Y-m-d")." 00:00:00");
$lap = ($now - $user_data['last_visit']);
$days_passed = ceil($lap / 86400);
if($days_passed == 0)   echo "Today";
elseif($days_passed == 1)  echo "Yesterday";
else echo $days_passed . " days ago";
?>

However, this looks bad when somebody hasn't logged in for years and it doesn't reflect the fact that you shouldn't hard code things like "Today" but instead use the lang files.
But I guess you got the direction wink

The German PunBB Site:
PunBB-forum.de

3

Re: Last visit

It's Perfect!!!

Thanks a bunch!

It was exactly what I was after and it work's great.

The forum is private.. and I wanted a easy way to see the activity so we don't need language file's and so on.

Cheers Carl