mdl_user table EPOCH Date fields

mdl_user table EPOCH Date fields

لە لایەن Kelly Turner -
Number of replies: 6

I'm trying to read the data from the mdl_user table. I have converted the epoch date to a date/time format I can uderstand. It appears that the mdl_user.firstaccess field is the date/time that the user account was created. However, in most records that I look at, I see no difference between the date/times of that particular users mdl_user.lastaccess, mdl_user.lastlogin and mdl_user.currentlogin.

For example - mdl_user.id = 343, has the mdl_user.lastaccess = 2/25/2008 6:15:05 PM, mdl_user.lastlogin = 2/25/2008 3:46:12 PM, mdl_user.currentlogin = 2/25/2008 6:14:40 PM.

What is the difference between these data fields?

Thanks,

تێکرایى نمرەپێدراوەکان: -
In reply to Kelly Turner

Re: mdl_user table EPOCH Date fields

لە لایەن Eloy Lafuente (stronk7) -
وێنەی Core developers وێنەی Documentation writers وێنەی Moodle HQ وێنەی Peer reviewers وێنەی Plugin developers وێنەی Testers
Hi Kelly,

if I'm not wrong these are the meaning for the three fields you are asking about:

- mdl_user.lastaccess: contains the last time the user has been active within Moodle (has performed some action). Note this field isn't updated for each "click" the user does, but

- mdl_user.currentlogin: contains the last time the user has logged-in.

- mdl_user.lastlogin: contains the "previous" last time the user has logged in (each time "currentlogin" is updated, before doing so, its value is copied to "lastlogin").

And then, as Tim commented, the table "user_lastaccess", whose lastaccess field contains the last time the user has been active (like the user one above) but BY COURSE (one record for each course the used has visited).

Ciao زەردەخەنە
In reply to Kelly Turner

Re: mdl_user table EPOCH Date fields

لە لایەن Chetan Sharma -

Hi Kelly,

Please tell me how have you converted that to date time format. Also i wanted to know how can i get the no. of days left in user's expiration for any course.

Thanks in Advance.

In reply to Chetan Sharma

Re: mdl_user table EPOCH Date fields

لە لایەن Guillermo Madero -

Hi Chetan,

Use the http://www.epochconverter.com/ page.

In reply to Guillermo Madero

Re: mdl_user table EPOCH Date fields

لە لایەن Chetan Sharma -

Hi Guillermo,

Thanks for your reply.

Actually i have created a different php file in the root of moodle and i want to call the no. of days left in the expiry of user. Please help me.

In reply to Chetan Sharma

Re: mdl_user table EPOCH Date fields

لە لایەن Guillermo Madero -

Hi Chetan,

That page includes sections with code samples in different languages; check the PHP one:

http://www.epochconverter.com/programming/functions-php.php

You could also take a look at the Moodle Enrolment plugins documentation page and at the links at the See also section of the Database schema introduction page.