Thread subject: Official Home of the PHPFusion CMS :: New function format_date not showing right time

Posted by douwe_yntema on 03-01-2023 13:16
#1

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

Posted by karrak on 04-01-2023 15:07
#2

displays the time well, but not the text (month or days)

Posted by karrak on 05-01-2023 18:01
#3

this might be the solution
https://github.com/PHPFusion/PHPFusio...ccda9b707d

Posted by douwe_yntema on 05-01-2023 19:19
#4

As said, PF8 not 9.....

Posted by Ernst74 on 06-01-2023 06:30
#5

Code
$lcmerid = explode('|', $locale['meridiem']wink;

can not be right. In Germany we have no am,pm or AM and PM for time.

Posted by douwe_yntema on 07-01-2023 16:04
#6

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

Posted by douwe_yntema on 12-01-2023 18:59
#7

Below is changed function showdate, fixes a bug with daylight saving time.

Maybe it can be imported in next update (if)

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

   if (isset($userdata['user_offset']wink) {
      $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"wink {
      return format_date($settings[$format], $val+$dls+($offset*3600));
   } else {
      return format_date($format, $val+$dls+($offset*3600));
   }
}

Posted by Falk on 13-01-2023 03:15
#8

Good work, submitted it
https://github.com/PHPFusion/PHPFusio...84e2dbc02d

Posted by afoster on 13-01-2023 17:31
#9

I have some version 8 sites online...where would I add/change this code douwe_yntema

Posted by douwe_yntema on 13-01-2023 19:04
#10

In maincore

Replace existing function