Page 1 of 1

PHP - debug error (fixed)

Unread postPosted: Thu, 9 October 2025, 3:30 am
by MOC
Recently, you may have noticed a PHP debug error at our forums. For full transparency of what the actual problem was, I will show the bad code that was causing the debug error, and the solution.

This is the debug error that was being displayed
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4596: date_interval_create_from_date_string(): Unknown or bad format ("9 hours 30 minutes") at position 0 ("): Unexpected character
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4596: date_sub() expects parameter 2 to be DateInterval, boolean given
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4598: date_interval_create_from_date_string(): Unknown or bad format ("9 hours 30 minutes") at position 0 ("): Unexpected character
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4598: date_add() expects parameter 2 to be DateInterval, boolean given


Problem: PHP used to execute the following code without debug errors
Code: Select all
(($tz == '9.5') ? '"9 hours 30 minutes"' : '')


Solution: PHP will now execute this version of the code effectively (remove " ")
Code: Select all
(($tz == '9.5') ? '9 hours 30 minutes' : '')

This debug error has been resolved.