Page 1 of 1

Wrong date value when picking a date by DateTime picker

Posted: Fri May 24, 2024 2:47 am
by mansour

Hi,
My default language is fa-IR and also my locale is set to fa-IR.
When I try to pick a date the value of the date is wrong. (The DateTime picker shows correct Persian calendar.)
e.g. when I try to pick 5/23/2054 (1402/03/03 in Hejri shamsi) the value of the date field is : Y-۲۵-۲۳ ۱۰:۲۵
What's the problem ?
Thanks


Re: wrong date value when picking a date by DateTime picker (2024)

Posted: Fri May 24, 2024 8:31 am
by mobhar

When you said it display the wrong date value, then what should be the correct one? Can you explain it in more detail?


Re: Wrong date value when picking a date by DateTime picker

Posted: Fri May 24, 2024 11:09 am
by mansour

Hi,
The calendar displayed correctly but after the date selection, the value of the field is NOT correct.
I selected 1403/03/03 (hejri shamsi) on the calendat but the value of the field shows as "Y-۲۵-۲۳ ۱۰:۲۵".
It should be 1403/03/03 or 2024/05/23

Thanks


Re: Wrong date value when picking a date by DateTime picker

Posted: Fri May 24, 2024 11:44 am
by mansour

Hi,
The console error:

Luxon failed to parse the input date.
tempus-dominus.js?v=24.11.0:4742

thanks


Re: Wrong date value when picking a date by DateTime picker

Posted: Fri May 24, 2024 12:45 pm
by arbei

mansour wrote:

e.g. when I try to pick 5/23/2054 (1402/03/03 in Hejri shamsi)...

mansour wrote:

I selected 1403/03/03 (hejri shamsi) on the calendat but the value of the field shows as "Y-۲۵-۲۳ ۱۰:۲۵".

  1. The date/time picker does not support Persian calendar,
  2. If your locale is "fa-IR", the correct format is "y/M/d", e.g. "2024/5/23", other formats are incorrect and cannot be parsed,
  3. If your database stores date values like "1402/03/03", the date/time picker will try to show but it will fail. When you select the date it returns a wrong date.
  4. You need to make sure your dates stored in the database are in the correct format, i.e. "y/M/d", e.g. "2024/5/23".

Re: Wrong date value when picking a date by DateTime picker

Posted: Fri May 24, 2024 12:50 pm
by mansour

Hi,
I found the problem is related to Locale setting. I removed the locale file for fa-IR, and the problem is fixed. Finally, I changed the date format to yyyy/MM/dd.
Thanks