Sign In
Not a member yet? Click here to register.
Forgot Password?
Navigation

New function format_date not showing right time

Last updated on 2 years ago
D
douwe_yntemaSenior Member
Posted 2 years ago
PF 8 comes with a new function format_date for replacement strftime function, which is deprecated in PHP > 8.1

When I call strftime on my server, time is correct
When I call format_date, time is one hour difference (one houre before)
Timezone is GMT+1
Seems the new function does not work with the time zone.
I tested on different sites
K
karrakSenior Member
Posted 2 years ago
displays the time well, but not the text (month or days)
K
karrakSenior Member
Posted 2 years ago
D
douwe_yntemaSenior Member
Posted 2 years ago
As said, PF8 not 9.....
E
Ernst74Junior Member
Posted 2 years ago
$lcmerid = explode('|', $locale['meridiem']);

can not be right. In Germany we have no am,pm or AM and PM for time.
D
douwe_yntemaSenior Member
Posted 2 years ago
It can be solved using showdate and set the correct server offset compensation. But fact is PF does not work with the time zone settings anymore
D
douwe_yntemaSenior Member
Posted 2 years ago
Below is changed function showdate, fixes a bug with daylight saving time.

Maybe it can be imported in next update (if)

// Format the date & time accordingly
function showdate($format, $val) {
   global $settings, $userdata;

   if (isset($userdata['user_offset'])) {
      $offset = $userdata['user_offset']+$settings['serveroffset'];
   } else {
      $offset = $settings['timeoffset']+$settings['serveroffset'];
   }
 // Correction for Daylight saving Time
 $dls = 0;
 if (date('I', $val+($offset*3600)) == 1){
 $dls = 3600;
 }

   if ($format == "shortdate" || $format == "longdate" || $format == "forumdate" || $format == "newsdate") {
      return format_date($settings[$format], $val+$dls+($offset*3600));
   } else {
      return format_date($format, $val+$dls+($offset*3600));
   }
}
F
FalkSuper Admin
Posted 2 years ago
A
afosterSenior Member
Posted 2 years ago
I have some version 8 sites online...where would I add/change this code douwe_yntema
D
douwe_yntemaSenior Member
Posted 2 years ago
In maincore

Replace existing function
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
You cannot set up a bounty in this discussion thread.
Moderator: Support Team
Users who participated in discussion: Falk, afoster, karrak, douwe_yntema, Ernst74

Fatal error: Uncaught Error: Class "PHPFusion\Minify" not found in /home/fusion/public_html/themes/templates/layout.php:206 Stack trace: #0 /home/fusion/public_html/themes/templates/footer.php(37): require_once() #1 /home/fusion/public_html/infusions/forum/viewthread.php(30): require_once('/home/fusion/pu...') #2 {main} thrown in /home/fusion/public_html/themes/templates/layout.php on line 206