How can I get give a format to dates or times in any of the moodle tables such as mdl_log. I am trying to create a SQL querry, using phpmyadmin and mysql, but I can not print the date sucessfully. I can only show the column time but when I try to use any of the SQL functions for dates there is always a error.
There is a PHP function - getdate() - that will convert the timestamps to a more readable format.
http://us2.php.net/manual/en/function.getdate.php
There is not a MySQL function that I am aware of that will convert the Unix time stamp to a "normal" date string.
http://us2.php.net/manual/en/function.getdate.php
There is not a MySQL function that I am aware of that will convert the Unix time stamp to a "normal" date string.
Even better, in moodlelib.php there is userdate. You typically use it like:
There are various date formats defined in the lang file, of if you leave out the format, it uses a sensible default.
Tim.
$date = userdate($transition->time, get_string('strftimerecent'));There are various date formats defined in the lang file, of if you leave out the format, it uses a sensible default.
Tim.
Many thanks for your help but how will you using Mysql and phpMyAdmin will give format to the date lastaccess column?.
SELECT `username`,CONCAT(`firstname`,' ',`lastname`) AS name,`email`,`lastaccess` FROM `mdl_user`
Ah, I see, I did not read the question carefully enough. You need the
http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#id2682338
FROM_UNIXTIME functionhttp://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#id2682338
What about using this:
select date_add('1970-01-01',interval round(timemodified/60/60/24) day) from mdl_quiz_grades;
If I understand your question correctly