[Question] Showing last login to user

Started by Rusconipepparoni, December 02, 2008, 01:08:43 AM

Previous topic - Next topic

Rusconipepparoni

Is it possible to show the last login to a user? Like it would say "Your last login was: 5 minutes ago" or "Last login: 07:08 am" something like that. Would be sweet, let me know =)

Rusconipepparoni

#1
I found this code on a mod:

if ($message['member']['last_login'] != '')
            echo '
', $txt['last_login'], ':', $message['member']['last_login'], '<br />';


Is there anyway I can use this to show my users when they logg on my website (Through SSI I suppose)

Edit: using ', $user_info['last_login'],' on my website gives me numbers that change all the time so I suppose it can be the time in seconds or some wierd way. That's the number 1228261620.

Anyone know?

Kermit

How about using this  ::)

$context['member']['last_login']
My Mods
Please don't PM/mail me for support,unless i invite you
Formerly known as Duncan85
Quote
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."

A. Einstein

Rusconipepparoni

#3
Quote from: Duncan85 on December 02, 2008, 07:59:21 PM
How about using this  ::)

$context['member']['last_login']

Doesn't work, shows up blank  :'(

Tried this code ', strftime('%B, %d, %Y', $context['user']['last_on']), '

Gives me December, 31, 1969, rofl. What's wrong? Current time on forum is December 02, 2008, 11:02:25 PM

Edit: Managed to get it working adding 'last_on' => &$user_info['last_login'], in Source/Load.php thanks to Bulakbol's post. But how can I make it so it shows my local time and not server time?

[SiNaN]

Use timeformat(). Example:

timeformat($user_info['last_login']);
Former SMF Core Developer | My Mods | SimplePortal

[SiNaN]

Would you please show what did you apply and what was the result? It would be easier to solve the issue in that way.
Former SMF Core Developer | My Mods | SimplePortal

Rusconipepparoni

Quote from: [SiNaN] on June 21, 2009, 12:13:21 PM
Would you please show what did you apply and what was the result? It would be easier to solve the issue in that way.

I solved it in another way now. Maybe you could tell me if it's good or not.

Using on my site:

Last login: <b>', strftime('%B %d, %I:%M %p', $user_info['last_login'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600), '

Adding following code to sources/load.php:

'last_on' => &$user_info['last_login'],

[SiNaN]

It's fine too but what if you make the first edit like this:

Last login: <b>', timeformat($user_info['last_login'], '%B %d, %I:%M %p'), '
Former SMF Core Developer | My Mods | SimplePortal

Rusconipepparoni

Quote from: [SiNaN] on June 22, 2009, 10:47:43 AM
It's fine too but what if you make the first edit like this:

Last login: <b>', timeformat($user_info['last_login'], '%B %d, %I:%M %p'), '

Would that display thier time offset, or the forums? Thanks for your help btw.

Edit: I'm at work, that's why I'm asking. Otherwise I'd try it myself

[SiNaN]

Yeah, it will take care of time offset too.
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: