Replace function userdate with following code
function userdate($date, $format = '', $timezone = 99, $fixday = true) {
global $CFG;
$strtimezone = NULL;
if (!is_numeric($timezone))
if (empty($format))
{ $format = get_string('strftimedaydatetime', 'langconfig'); }if (!empty($CFG->nofixday))
{ // Config.php can force %d not to be fixed. $fixday = false; }else if ($fixday)
{ $formatnoday = str_replace('%d', 'DD', $format); $fixday = ($formatnoday != $format); } //$date += dst_offset_on($date, $strtimezone);
$dst = dst_offset_on($date, $strtimezone);
$date +=$dst;
$timezone = get_user_timezone_offset($timezone);
global $SESSION;
if(isset($SESSION->dst_offsettz) && trim($SESSION->dst_offsettz)!='')
if (abs($timezone) > 13) { /// Server time
if ($fixday)
else
{ $datestring = strftime($format, $date); } } else {
$date += (int)($timezone * 3600);
if ($fixday)
else
{ $datestring = gmstrftime($format, $date); }}
/// If we are running under Windows convert from windows encoding to UTF-8
/// (because it's impossible to specify UTF-8 to fetch locale info in Win32)
if ($CFG->ostype == 'WINDOWS') {
if ($localewincharset = get_string('localewincharset', 'langconfig'))
}
return $datestring;
}
/*
- Function to change the date format from strftime supported format(e.g. %Y-%m-%d) to php date function format(Y-m-d)
*/
function strftime_to_dateformat($strftime_format) {
$caracs = array(
// Day - no strf eq : S
'd' => '%d', 'D' => '%a', 'j' => '%e', 'l' => '%A', 'N' => '%u', 'w' => '%w', 'z' => '%j',
// Week - no date eq : %U, %W
'W' => '%V',
// Month - no strf eq : n, t
'F' => '%B', 'm' => '%m', 'M' => '%b',
// Year - no strf eq : L; no date eq : %C, %g
'o' => '%G', 'Y' => '%Y', 'y' => '%y',
// Time - no strf eq : B, G, u; no date eq : %r, %R, %T, %X
'a' => '%P', 'A' => '%p', 'g' => '%l', 'h' => '%I', 'H' => '%H', 'i' => '%M', 's' => '%S',
// Timezone - no strf eq : e, I, P, Z
'O' => '%z', 'T' => '%Z',
// Full Date / Time - no strf eq : c, r; no date eq : %c, %D, %F, %x
'U' => '%s'
);
$caracs = array_flip($caracs);
return strtr((string)$strftime_format, $caracs);
}
/*
- For adjusting DST value for those timezones which are running under DST for a date ot datetime
*/
function adjust_dsttimezone($date, $tz, $format='Y-m-d g:i A',$dst=0) {
if(strstr($format, '%') != '') { $format = strftime_to_dateformat($format); }$timezone = new DateTimeZone($tz);
{ $datetime->modify('+'.trim($dst).' seconds'); }
$datetime = new DateTime(date('c', $date));
$datetime->setTimeZone($timezone);
if($dst > 0)return $datetime->format($format);
}