Hi, I don't know if this is the right place to post, but I couldn't find anywhere more appropriate. I was wondering what the conversion is for the 'time' in the mdl_log table (e.g. 1130887594) to real date and time?
Thanks
Caz
Somebody correct me if I am wrong, but this is a Unix timestamp (I think the amount of seconds since 1-1-1970). In PHP there are couple of functions to convert this to something understandable. See for example the date() function.
Regards, Hans
Regards, Hans
And if you want to convert the values manually during testing (I do sometimes), no need to waste time using PHP scripts; there are online converters, such as:
http://www.onlineconversion.com/unix_time.htm
It might be argued that using the database's time format would be better practice than just storing the Unix time (this would allow you to see the time in normal format just by looking at the database). I would personally take that position, but there are arguments for doing it the way Moodle does, as it relies less on database features.
--sam
http://www.onlineconversion.com/unix_time.htm
It might be argued that using the database's time format would be better practice than just storing the Unix time (this would allow you to see the time in normal format just by looking at the database). I would personally take that position, but there are arguments for doing it the way Moodle does, as it relies less on database features.
--sam
It's also possible to do this if you have access to a Unix command line with the command:
date -d @#NUMBER#
ie:
[root@webbox root]# date -d @1130887594
Wed Nov 2 07:26:34 WST 2005
Or you can use the built-in MySQL functions
Richard
date -d @#NUMBER#
ie:
[root@webbox root]# date -d @1130887594
Wed Nov 2 07:26:34 WST 2005
Or you can use the built-in MySQL functions
CheersUNIX_TIMESTAMP()
FROM_UNIXTIME() in the context: select
UNIX_TIMESTAMP(UnixStored_Field)
from tblMyDatabase where 1=1
Richard
In reply to Richard M
Re: How does date / time in DB convert to real Date / Time?
by peshala amarasingha -
This was really helpful thanx......
if you use moodle 1.9 , there is a moodle function userdate($time)
hope this answers your problem...
I use this function I found at http://www.weberdev.com/get_example-3113.html
function GetTimeStamp($MySqlDate)
{
/*
Take a date in yyyy-mm-dd format and return it to the user in a PHP timestamp
Robin 06/10/1999
*/
$date_array = explode("-",$MySqlDate); // split the array
$var_year = $date_array[0];
$var_month = $date_array[1];
$var_day = $date_array[2];
$var_timestamp = mktime(0,0,0,$var_month,$var_day,$var_year);
return($var_timestamp); // return it to the user
}
and it works just fine
That is not relevant to Moodle. Moodle uses unix timestamps, not MySQL datetimes.