joomlaboat / custom-tables

The Custom Tables extension allows you to create, manage, and display custom data on your Joomla site. It is helpful if you need to display data that is not part of the standard Joomla content structure. For example, you could use this extension to create a custom table for product information, customer data, or any other type of data that you need to display on your site. The Custom Tables is the CRUD solution for Joomla 3.x and 4.x - CREATE, READ, UPDATE and DELETE. You can add tables, fields, and layouts to create catalogs, forms, or details pages. It has 40 Field Types: Integer (numbers), Decimal, Text String, Time, Email, Color, Image, File, User, Language, etc.
https://joomlaboat.com/custom-tables
GNU General Public License v2.0
35 stars 11 forks source link

Date-only field displays incorrect date in layout with defined date format #78

Open AndreasHauri opened 5 months ago

AndreasHauri commented 5 months ago

A date-only field formatted with a date format like "{{ date("Y-m-d") }}" shows the wrong date. E.g. selecting 2024-02-25 in the editing, shows the "2024-02-24". in the layout display. If I remove the format "{{ date }}", it shows the correct date "Sonntag, 25. Februar 2024".

If I add the time {{ date("Y-d-m h:m") }}, even if it's a date format, it shows the reason, there is a time shift: "2024-24-02 11:02". That's why it shows the wrong date.

It's an issue of the current version 3.2.4. If I downgrade it to an older version 3.1.0 (That's the only old version I have), everything is fine.

joomlaboat commented 4 months ago

Its about the Time Zone settings in the PHP ini file.

AndreasHauri commented 4 months ago

Sorry to bother you again. I cannot find a problem. The phpinfo() shows the correct timezone "Europe/Zurich". When I check this PHP function, it shows the correct time for the country: date("Y.m.d h:i:sa")

If I check the timezone offset in the MySQL Database, it is correct: SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP);

Do you have any idea what the problem is?

joomlaboat commented 4 months ago

What if you add Z keyword to set the timezone offset?

https://www.w3schools.com/php/func_date_date.asp

AndreasHauri commented 4 months ago

If I add the Z, it shows the correct offset of 3600 seconds for Zurich.

joomlaboat commented 4 months ago

Problem solved?

AndreasHauri commented 4 months ago

I have just added the "Z" to my test script and everything looks fine in the result of my script. But in the custom-tables module, the problem is still there. Was the suggestion to add the 'Z' somewhere else? My problem is not solved yet.

joomlaboat commented 4 months ago

To the field output tag {{ date("Y-d-m h:m Z") }}

AndreasHauri commented 4 months ago

If I add the "Z" to the output tag, it shows the offset of 0 instead of the 3600 for Zurich. If I create a own php file in the root folder of my website with the date("Z"), it shows the offset of 3600.

joomlaboat commented 3 months ago

Hello Andreas,

I replaced all date formatting methods with one that always checks the Joomla Website Time Zone.

Please try the update from here, from GitHub.

AndreasHauri commented 2 months ago

Great, it works. Thank you!