/** * Formats a timestamp as desired based on a language string and the user's time zone * * @param int $timestamp The timestamp to format * * @return string The formatted date */ function format_date($timestamp) { //handle special cases if ($timestamp === '0') { //the zero timestamp return get_string('na', $this->languagefile); } else { if (empty($timestamp)) { //NULL column return ''; } } //determine the format $format = get_string('date_format', $this->languagefile); //figure out the correct timezone $timezone = 99; if ($user_record = get_record('user', 'id', $this->userid)) { //determine the user's timezone $timezone = php_report::get_user_timezone($user_record, $user_record->timezone); } //perform the formatting return userdate($timestamp, $format, $timezone, false); }
/** * from /lib/moodlelib.php::userdate() * Returns a formatted string that represents a date in user time * * @param int $date timestamp in GMT * @param string $format strftime format * @param bool $fixday If true then the leading zero from %d is removed. * If false (default) then the leading zero is mantained. * @return string */ function userdate($date, $format = '', $fixday = false) { // TBD: false??? $timezone = 99; if ($user_record = get_record('user', 'id', $this->userid)) { //determine the user's timezone $timezone = php_report::get_user_timezone($user_record, $user_record->timezone); } //perform the formatting return userdate($date, $format, $timezone, $fixday); }
/** * Formats a timestamp as desired based on a language string and the user's time zone * * @param int $timestamp The timestamp to format * * @return string The formatted date */ function format_date($timestamp) { //determine the format $format = get_string('date_format', 'rlreport_course_completion_by_cluster'); //figure out the correct timezone $timezone = 99; if ($user_record = get_record('user', 'id', $this->userid)) { //determine the user's timezone $timezone = php_report::get_user_timezone($user_record, $user_record->timezone); } //perform the formatting return userdate($timestamp, $format, $timezone, false); }