Welcome Guest, Not a member yet? Register   Sign In
Time diff NOT WORKING
#3

(This post was last modified: 03-24-2024, 05:50 AM by pablo.hernandez.)

(03-24-2024, 02:07 AM)pablo.hernandez Wrote:
(03-23-2024, 07:25 PM)kenjis Wrote: Cannot reproduce.
PHP 8.2.16
PHP 7.4.33

PHP Code:
$date1 = new Time("2024-03-31");
$date2 = new Time("2024-04-01");

echo 
$date1->difference($date2)->days;  // 1 

Thank you for your reply; you are right, if I set up a brand new install of CI 4.4.6, no database setup, and put that code in the welcome_page view and IT WORKS (shows "1")

However, when I edit the app\Config\App.php file and change it for SPANISH LOCALE it STOPS WORKING for this example (shows "0")!

These are the lines changed in my App.php file:

PHP Code:
public string $defaultLocale 'es';
public array 
$supportedLocales = ['es'];
public 
string $appTimezone 'Europe/Madrid'

After some testing I've noticed that it is specifically the third line ($appTimezone) that is causing the error (if I change it back to UTC, the method throws "1" again!). It is a very strange behaviour because other date combinations do work with the modified App.php file, and according to the link included in that file just above the $appTimezone setting (https://www.php.net/manual/en/timezones.php), the string I'm using for the time zone should be valid.

The problem appears with any "Europe/X" city that I've tried (Amsterdam, Paris...)

Many thanks!
Reply


Messages In This Thread
Time diff NOT WORKING - by pablo.hernandez - 03-23-2024, 06:25 AM
RE: Time diff NOT WORKING - by kenjis - 03-23-2024, 07:25 PM
RE: Time diff NOT WORKING - by kenjis - 03-24-2024, 02:35 AM
RE: Time diff NOT WORKING - by MaxWho17 - 03-24-2024, 02:53 AM
RE: Time diff NOT WORKING - by bobw - 03-24-2024, 06:12 AM
RE: Time diff NOT WORKING - by kenjis - 03-24-2024, 04:11 PM
RE: Time diff NOT WORKING - by pablo.hernandez - 03-25-2024, 04:15 AM
RE: Time diff NOT WORKING - by kenjis - 03-25-2024, 05:01 PM
RE: Time diff NOT WORKING - by kenjis - 03-25-2024, 05:25 PM
RE: Time diff NOT WORKING - by kenjis - 03-25-2024, 08:10 PM
RE: Time diff NOT WORKING - by pablo.hernandez - 03-26-2024, 10:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB