Open Closed

Date filter format error (dd/MM/yyyy) #9619


User avatar
0
lilot18 created
  • ABP Framework version: v9.1.3
  • UI Type: MVC
  • Database System: PostgreSQL
  • Tiered (for MVC) or Auth Server Separated (for Angular): no

Hi,

I have all my dates set up as DataOnly. When I switch the UI language to Italian and try to filter by date, I get an error if the day is greater than 12. For example: The value '31/07/2025' is not valid for PaymentDateMin. It seems that the date is being parsed in US format (MM/DD/YYYY) instead of the correct format based on the selected language (in this case, DD/MM/YYYY for Italian). Is there a way to automatically parse date filters according to the language set in the UI? Thanks in advance for your help!


6 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    To ensure that date filters in ABP MVC applications are parsed according to the selected UI language (e.g., DD/MM/YYYY for Italian), you need to configure both the client-side and server-side to use the correct culture settings.

    1. Set the Culture in Startup: Make sure your application is configured to use the correct culture based on the user's selection. In Startup.cs (or Program.cs for .NET 6+), configure localization:

    var supportedCultures = new[] { "en-US", "it-IT" }; app.UseRequestLocalization(new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture("it-IT"), SupportedCultures = supportedCultures.Select(c => new CultureInfo(c)).ToList(), SupportedUICultures = supportedCultures.Select(c => new CultureInfo(c)).ToList() });

    
    2. **Client-Side Date Format:**
       If you are using DataTables or similar components, ensure the date picker and filter inputs use the correct format. For example, set the date picker to use `DD/MM/YYYY` for Italian.
    
       ```javascript
    $('#PaymentDateMin').datepicker({
           format: 'dd/mm/yyyy',
           language: 'it'
       });
    
    1. Model Binding and Validation: ASP.NET Core model binding uses the current culture to parse dates. If the request culture is set correctly (as above), the model binder will expect dates in the format of the current culture.

    2. HTML Input Type: If you use <input type="date">, browsers may enforce the yyyy-MM-dd format regardless of culture. To allow localized input, use <input type="text"> with a date picker that matches the culture.

    3. Summary:

      • Ensure the request culture matches the UI language.
      • Use a date picker that outputs dates in the correct format.
      • Avoid <input type="date"> if you want localized formats.
      • The ABP framework will respect the current culture for parsing if configured as above.

    This approach ensures that date filters are parsed according to the selected UI language, preventing errors like the one you described.

    Sources:

    • https://abp.io/docs/latest/framework/ui/mvc-razor-pages/data-tables

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    lilot18 created

    Hi, Thanks for the suggestion, but unfortunately it doesn’t seem to solve the issue in my case. The problem with the date parsing is still occurring when the UI language is set to Italian. Looking forward to any other ideas or a fix from the support team.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    try to filter by date

    On which page do you get the error when the language is Italian?

    Can you share a screenshot?

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    BTW, we enhanced the time-related feature in 9.2.0.

    https://github.com/abpframework/abp/blob/dev/docs/en/Community-Articles/2025-03-11-Developing-A-Multi-Timezone-Application-Using-The-ABP-Framework/post.md

    Can you try upgrading to 9.2.0 or testing your case in a new 9.2.2 template project?

    Thanks.

  • User Avatar
    0
    lilot18 created

    Hi, I have created a new 9.2.2 template project and a new simple entity: If I set the language to EN and filter by date, no problem: But, if I set the language to IT and try to filter, I have this error:

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi

    Thanks, I will update the suite code.

    You can test the module page. Eg identity user page

    You need to call the handleDatepicker method before sending the Ajax request

    See

    When we submit the form, we need to convert the time to UTC. In the JavaScript of the Create and Editpages, we use the handleDatepickerthis jQuery extension method to handle time in the form, it internally gets the user's local time from the selector input[type="hidden"][data-hidden-datepicker], and then uses the abp.clock.normalizeToString method to convert the date field in the form to the ISO 8601 format UTC time string.

    https://github.com/abpframework/abp/blob/dev/docs/en/Community-Articles/2025-03-11-Developing-A-Multi-Timezone-Application-Using-The-ABP-Framework/post.md

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 01, 2025, 08:37