if ( $userdata['user_id'] != ANONYMOUS )
{
switch ( $userdata['user_time_mode'] )
{
case MANUAL_DST:
$dst_sec = $userdata['user_dst_time_lag'] * 60;
return ( !empty($translate) ) ? strtr(gmdate($format, $gmepoch + (3600 * $tz) + $dst_sec), $translate) : gmdate($format, $gmepoch + (3600 * $tz) + $dst_sec);
break;
case SERVER_SWITCH:
if (!empty($gmepoch) && is_long($gmepoch)) {
$dst_sec = date('I', $gmepoch) * $userdata['user_dst_time_lag'] * 60;
} else {
$dst_sec = date('I') * $userdata['user_dst_time_lag'] * 60;
}
return ( !empty($translate) ) ? strtr(gmdate($format, $gmepoch + (3600 * $tz) + $dst_sec), $translate) : gmdate($format, $gmepoch + (3600 * $tz) + $dst_sec);
break;
case FULL_SERVER:
return ( !empty($translate) ) ? strtr(date($format, $gmepoch), $translate) : date($format, $gmepoch);
break;
case SERVER_PC:
if ( isset($pc_dateTime['pc_timezoneOffset']) )
{
$tzo_sec = $pc_dateTime['pc_timezoneOffset'];
} else
{
$user_pc_timeOffsets = explode("/", (string) $userdata['user_pc_timeOffsets']);
$tzo_sec = $user_pc_timeOffsets[0];
}
return ( !empty($translate) ) ? strtr(gmdate($format, $gmepoch + $tzo_sec), $translate) : gmdate($format, $gmepoch + $tzo_sec);
break;
case FULL_PC:
if ( isset($pc_dateTime['pc_timeOffset']) )
{
$tzo_sec = $pc_dateTime['pc_timeOffset'];
} else
{
$user_pc_timeOffsets = explode("/", (string) $userdata['user_pc_timeOffsets']);
$tzo_sec = $user_pc_timeOffsets[1] ?? '';
}
return ( !empty($translate) ) ? strtr(gmdate($format, $gmepoch + $tzo_sec), $translate) : gmdate($format, $gmepoch + $tzo_sec);
break;
default:
return ( !empty($translate) ) ? strtr(gmdate($format, $gmepoch + (3600 * $tz)), $translate) : gmdate($format, $gmepoch + (3600 * $tz));
break;
}
} else
{
switch ( $board_config['default_time_mode'] )
{
case MANUAL_DST:
$dst_sec = $board_config['default_dst_time_lag'] * 60;
return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz) + $dst_sec), $translate) : @gmdate($format, $gmepoch + (3600 * $tz) + $dst_sec);
break;
case SERVER_SWITCH:
if (!empty($gmepoch) && is_long($gmepoch)) {
$dst_sec = date('I', $gmepoch) * $userdata['user_dst_time_lag'] * 60;
} else {
$dst_sec = date('I') * $userdata['user_dst_time_lag'] * 60;
}
return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz) + $dst_sec), $translate) : @gmdate($format, $gmepoch + (3600 * $tz) + $dst_sec);
break;
case FULL_SERVER:
return ( !empty($translate) ) ? strtr(@date($format, $gmepoch), $translate) : @date($format, $gmepoch);
break;
case SERVER_PC:
if ( isset($pc_dateTime['pc_timezoneOffset']) )
{
$tzo_sec = $pc_dateTime['pc_timezoneOffset'];
} else
{
$tzo_sec = 0;
}
return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + $tzo_sec), $translate) : @gmdate($format, $gmepoch + $tzo_sec);
break;
case FULL_PC:
if ( isset($pc_dateTime['pc_timeOffset']) )
{
$tzo_sec = $pc_dateTime['pc_timeOffset'];
} else
{
$tzo_sec = 0;
}
return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + $tzo_sec), $translate) : @gmdate($format, $gmepoch + $tzo_sec);
break;
default:
return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
break;
}
}
RECTOR just let it slip right by even after multiple runs...
This code is used by the CMS to let the user choose to use the server time, DST server time, and they can also manually choose other time and date options.
- Server universal time, Timezone/DST
- from your computer
- Server local time
Manual mode...
- DST enable:Yes No* By the server
- DST difference: 0
- Timezone: UTC= 5 Hours
Each user is allowed to set a time mode via their profile.
I am new to PHP 8, I've tried different formats to no avail.
This code works in PHP 7.4
I have very little experience working with the gmdate function in PHP 7.4.
Any help I could get with formatting this correctly would greatly be appreciated.
Thanks, Ernest
FIXED: Removed error control - PHP 8.1 does not support @
Warning
Prior to PHP 8.0.0, the error_reporting() called inside the custom error handler always returned 0 if the error was suppressed by the @ operator.
As of PHP 8.0.0, it returns the value E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE.