No Code Attached Yet Information Required
avatar micker
micker
11 Feb 2022

hello i have strange problem with calendar custom field ...

1 i create one date field no specific configuration

2 but date isn't good in backend and i didn't find where in can change format ...

3 if user set a date via selector that display 10-02-2022 for 10 feb 2022 (french format) that display in front 2 october 2022
I didn't think its an output problem because if is set 24-02-2022 (24 feb 2022)
in front it crashed because systeme think month number 24 that doesn't exist ....

Some body can confirm ?
Bug config problem ?

2022-02-10_11h20_08
2022-02-10_11h20_41
2022-02-10_11h21_48

avatar micker micker - open - 11 Feb 2022
avatar joomla-cms-bot joomla-cms-bot - change - 11 Feb 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 11 Feb 2022
avatar micker micker - change - 11 Feb 2022
The description was changed
avatar micker micker - edited - 11 Feb 2022
avatar richard67
richard67 - comment - 11 Feb 2022

@Fedik Any idea?

avatar Bakual
Bakual - comment - 11 Feb 2022

Which version of the language pack are you using?
The format is converted using four language strings provided by the language pack. You may want to check those:

DATE_FORMAT_CALENDAR_DATE="%d-%m-%Y"
DATE_FORMAT_CALENDAR_DATETIME="%d-%m-%Y %H:%M:%S"
DATE_FORMAT_FILTER_DATE="d-m-Y"
DATE_FORMAT_FILTER_DATETIME="d-m-Y H:i:s"

These are taken from the official pack from https://downloads.joomla.org/de/language-packs/translations-joomla4/downloads/joomla4-french/4-0-6-1 and look correct.

Can you also check what is stored in the database? Should be in the english format (2022-02-10)

avatar Fedik
Fedik - comment - 11 Feb 2022

It as @Bakual said.

Use default system format for your language.
There not only "calendar format", but also "format for filter", that must be in sync.

If you changing "calendar format" you also must change "format for filter".

avatar richard67 richard67 - change - 11 Feb 2022
Labels Added: Information Required
avatar richard67 richard67 - labeled - 11 Feb 2022
avatar micker
micker - comment - 11 Feb 2022

hello
1 i update language to last package
2 i update any item to 31/02/2022
image
when i load item
image
to load my code i use this
echo HtmlHelper::date($this->item->arbitrary_property_name['date-de-parution']->value, Text::_('DATE_FORMAT_LC3'));
3 format of date in database 2020-01-31 14:03:03

if is set this
image
display works but wrong date
image

avatar Fedik
Fedik - comment - 11 Feb 2022

Please post what value for this language constants on your admin/site:

DATE_FORMAT_CALENDAR_DATE
DATE_FORMAT_CALENDAR_DATETIME
DATE_FORMAT_FILTER_DATE
DATE_FORMAT_FILTER_DATETIME

You can try search them in language override

avatar micker
micker - comment - 11 Feb 2022

DATE_FORMAT_CALENDAR_DATE = "%d-%m-%Y"
DATE_FORMAT_CALENDAR_DATETIME = "%d-%m-%Y %H:%M:%S"
DATE_FORMAT_FILTER_DATE ="d-m-Y"
DATE_FORMAT_FILTER_DATETIME = "d-m-Y H:i:s"
seems correct

avatar Fedik
Fedik - comment - 11 Feb 2022

hm yes, strange then why it fail

avatar micker
micker - comment - 11 Feb 2022

lol i take many time to find why item is failed ... lol
tahnks for your help

avatar Fedik
Fedik - comment - 11 Feb 2022

What value for DATE_FORMAT_LC3?
and what happen if you just do echo HTMLHelper::_('date', $blablaDateValue) (without use of format)?

avatar richard67
richard67 - comment - 11 Feb 2022

What's the value of DATE_FORMAT_LC3? If you use that for creating your date, it has to be the ISO format?

avatar richard67
richard67 - comment - 11 Feb 2022

It seems @Fedik and me just had the same idea. 😄

avatar Bakual
Bakual - comment - 11 Feb 2022

Since the calendar field apparently stores the date correctly into the database in format YYYY-MM-DD, and the calendar field also correctly shows the date again, something must be wrong with your code to display the date in frontend.
I doubt the issue is the DATE_FORMAT_LC3 either, as that one should not create such issues when being wrong.

I rather suspect your $this->item->arbitrary_property_name['date-de-parution']->value doesn't hold the date as it is in the database but is already transformed to another format, which is why the date function then breaks.
This value has to be in the format YYYY-MM-DD.

avatar micker
micker - comment - 11 Feb 2022

hello i think @Bakual you are right
this <?php echo $this->item->arbitrary_property_name['date-de-parution']->value;?> display 10/01/2020 that the good date ...
how i can format it on html output ? can i use joomla format ?

avatar Bakual
Bakual - comment - 11 Feb 2022

Joomla always expects YYYY-MM-DD. The same as is stored in the database. So you need to check your code why the value is already localised. You probably already applied the date format on that property and now try to apply it a second time, which fails.

avatar micker micker - change - 14 Feb 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-02-14 08:01:19
Closed_By micker
avatar micker micker - close - 14 Feb 2022
avatar micker
micker - comment - 14 Feb 2022

ok thanks i close this thank for all

Add a Comment

Login with GitHub to post a comment