Echo last login / register date

Ask all your questions about the script here.
never-in-doubt
New
Posts: 14
Joined: Wed Nov 02, 2016 6:31 am

Echo last login / register date

Postby never-in-doubt » Wed Nov 02, 2016 6:33 pm

Wondering if anyone can help with capturing & echoing the registration date and the last login date / time?

So assume on the members.php page, when I'm logged in it will echo my last visit and my registration date.

Thanks in advance :)
User avatar
Douglas
Site Admin
Posts: 625
Joined: Sat Oct 27, 2007 11:29 pm
Location: BC, Canada
Contact:

Re: Echo last login / register date

Postby Douglas » Sat Nov 05, 2016 5:13 pm

I don't think I wrote it to store the registration time, but I wrote in to save the activation time. In the users database there are two fields you can use:

Code: Select all

last_login
activation_time


These contain the UNIX time stamp of the last time a user was logged in successfully, and the time they activated their accounts. PHP has a date function which converts these values into readable format. Do you know much coding, or should I explain further?
never-in-doubt
New
Posts: 14
Joined: Wed Nov 02, 2016 6:31 am

Re: Echo last login / register date

Postby never-in-doubt » Sun Nov 06, 2016 1:55 am

Hi Douglas

I've not tested yet but I guess it's similar to:

$qls->user_info['last_login']
$qls->user_info['activation_time']

If not please advise if that's ok. I'll get it working now I know the field names :)
User avatar
Douglas
Site Admin
Posts: 625
Joined: Sat Oct 27, 2007 11:29 pm
Location: BC, Canada
Contact:

Re: Echo last login / register date

Postby Douglas » Sun Nov 06, 2016 10:21 am

Indeed that is the proper way to access it!
never-in-doubt
New
Posts: 14
Joined: Wed Nov 02, 2016 6:31 am

Re: Echo last login / register date

Postby never-in-doubt » Mon Nov 07, 2016 4:04 am

Douglas wrote:Indeed that is the proper way to access it!


The activation date displays as 1970 - any idea's how to sort this?

Code reads as:

Code: Select all

<strong>Activation Date:</strong> <?php echo gmdate('D d M Y', $qls->user_info['activation_time']); ?></br />


The last login date works fine, but seems the activation date is displaying the UNIX start date.

Thoughts...
User avatar
Douglas
Site Admin
Posts: 625
Joined: Sat Oct 27, 2007 11:29 pm
Location: BC, Canada
Contact:

Re: Echo last login / register date

Postby Douglas » Mon Nov 07, 2016 5:29 pm

It could very well be that the code is not inserting the activation date if you don't have activation turned on. If you don't, this date will always just be 0 (or 1970 in years). This could be changed just by taking the code which updates this field and having it so that on successful registration the field is updated.
never-in-doubt
New
Posts: 14
Joined: Wed Nov 02, 2016 6:31 am

Re: Echo last login / register date

Postby never-in-doubt » Mon Nov 07, 2016 5:59 pm

Could you be more specific please, change what & where. I've got it set as admin to authorise / activate all members.

Thanks :)
User avatar
Douglas
Site Admin
Posts: 625
Joined: Sat Oct 27, 2007 11:29 pm
Location: BC, Canada
Contact:

Re: Echo last login / register date

Postby Douglas » Tue Nov 08, 2016 1:52 pm

Look into includes/User.class.php in this function:

Code: Select all

insert_registration_data


You will see a list of columns and their values when they're inserted into the database. You should see that the column for activation time is set to zero!
never-in-doubt
New
Posts: 14
Joined: Wed Nov 02, 2016 6:31 am

Re: Echo last login / register date

Postby never-in-doubt » Tue Nov 08, 2016 4:25 pm

Douglas wrote:Look into includes/User.class.php in this function:

Code: Select all

insert_registration_data


You will see a list of columns and their values when they're inserted into the database. You should see that the column for activation time is set to zero!


Found that but I am totally lost as to what goes in there instead of 0.... I did say php isn't my strongest point :)

Can you please give me an idea of what needs doing cos it's baffling me here - thanks again.
User avatar
Douglas
Site Admin
Posts: 625
Joined: Sat Oct 27, 2007 11:29 pm
Location: BC, Canada
Contact:

Re: Echo last login / register date

Postby Douglas » Tue Nov 22, 2016 9:53 am

I thought I replied to this sorry, you should probably just use the PHP time function there.

Code: Select all

time()


Find the entry in the values list that corresponds to the activation_time field, they should be the same amount down. Does this make sense?

Return to “Support”

Who is online

Users browsing this forum: No registered users and 1 guest