'timemodified' field format

'timemodified' field format

Jason Lea -
回帖数:11
In table such as mdl_quiz_attempts and mdl_assignment_submissions there is a field called 'timemodified'. That field displays what looks like random numbers, and not the date/time. How can one actually view the dat/time?

Much help would be appreciated 微笑
平均分:Useful (1)
回复Jason Lea

Re: 'timemodified' field format

Jon Witts -
Plugin developers的头像 Testers的头像
All time fields in the Moodle database are stored in UNIX time format. http://en.wikipedia.org/wiki/Unix_time There ways to convert this to a more human readable format using formulas in excel etc. or on-line converters like: http://www.epochconverter.com/

Jon
回复Jon Witts

Re: 'timemodified' field format

Jason Lea -
oh right, never knew that thanx.

but the million dollar question is if i run a query and pump the query into a csv will it display the proper time or the UNIX time?
回复Jason Lea

Re: 'timemodified' field format

Jon Witts -
Plugin developers的头像 Testers的头像
It will output as UNIX time. In M$ Excel you can convert Unix time to GMT using the following equation:

=UnixTime / 86400 + 25569


You would then need to apply a date / time format to the field as this will return the date time in the excel time serial.

回复Jon Witts

Re: 'timemodified' field format

Luis de Vasconcelos -
Particularly helpful Moodlers的头像

What is the 25569 in that formula?

回复Luis de Vasconcelos

Re: 'timemodified' field format

Itamar Tzadok -

The date value of Jan. 1 1970. See explanation of conversion e.g. here. 微笑

回复Itamar Tzadok

Re: 'timemodified' field format

Luis de Vasconcelos -
Particularly helpful Moodlers的头像

Thanks.

Does Moodle store all dates using standard UTC time, or does it use the time zone of the web server that Moodle is hosted on? In other words, if the time zone on my server is UTC + 1 will Moodle store all dates as UTC + 1, or are they always stored as UTC?

回复Luis de Vasconcelos

Re: 'timemodified' field format

Itamar Tzadok -

The database activity stores entries time as unix timestamp which may be regarded as offset from 1/1/1970 UTC and timezone independent. The rest depends on your server configuration. From what I've seen so far, this seems the standard Moodle approach to time handling. 微笑

回复Itamar Tzadok

Re: 'timemodified' field format

Luis de Vasconcelos -
Particularly helpful Moodlers的头像

So Moodle core stores the unix dates as per the timezone settings on the web server, i.e. UTC + 1 for a server in the UTC +1 timezone? Have I understood you correctly?

回复Luis de Vasconcelos

Re: 'timemodified' field format

Itamar Tzadok -

Not quite but only because I wasn't clear enough. Moodle core stores a unix timestamp which is indifferent to timezone. It is only on display that timezones may come to effect and for that displaying time in moodle should be done through a lib function which looks for site admin timezone setting or user pref. In site admin setting the default is server local time and you can select any time zone and do or don't force it. You can also use the default and config your server local time to a desired timezone. 微笑

回复Itamar Tzadok

Re: 'timemodified' field format

Luis de Vasconcelos -
Particularly helpful Moodlers的头像

Thanks. I think I understand! Moodle always stores the offset from 1/1/1970 UTC, regardless of any timezones. Then the lib function handles the timezone conversions based on how the site admin has configured the Moodle site.

If I create a form that requires the user to capture a date will those user dates be saved to the database according to the timezone on my server, or as the offset from 1/1/1970 UTC? In other words, does the Moodle lib convert the dates that the user captures into the timezone indifferent offset?

回复Luis de Vasconcelos

Re: 'timemodified' field format

Itamar Tzadok -

Moodle's treatment of user input with respect to date/time values may differ from module to module depending on purpose. In the database module, user input in the date field is converted to server/user timezone according to the admin settings before storing in the database. Suppose than that a user adds a new entry with a date field and enters the current date. Since the user input is converted according to timezone but the internal timemodified is not, this may create a 1 day difference between the entry modified date and the user's date input, under certain timezone settings, unless you force server time. Hope that clarifies more than confuses. 微笑