Open Closed

How can I change Hijri date to Gregorian date in date picker ? #3439


User avatar
0
Merna created

Hello, Our application support 2 languages, Arabic (ar) and English (en), so we faced an issue using a date picker when UI Culture is ar. It returns in Hijri format, not Gregorian format when its type is Date Time, not a string.

How can I specify only Gregorian date format without using current culture please?

Thanks in advance

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

14 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    HI,

    May I ask which UI and ABP version are you using?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Merna created

    Hello , ABP Framework version: v5.1 UI type: MVC

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Is the page HostDashboard.cshtml?

    I can't reproduce

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Merna created

    hello , Here is the languages we use in our application .

    Steps : 1-Use Ar languages 2- select date then search **(Before Submitting)

    **(After Submitting) years only in dates is return in hijri but wrongly cause now we are in 1443 not 1422

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer
    <div class="input-group">
        <span class="input-group-text">@L["StartDate"].Value</span>
        <input type="text"
               class="form-control"
               name="StartDate"
               value="@DateTime.Now.AddMonths(-1).Date.ToString(CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern)" />
    </div>
    

    Maybe you can change the culture here.

    MyCompanyName.MyProjectName.Web\Pages\HostDashboard.cshtml

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Merna created

    Hello , I have tried to add input hidden in my application to add this solution but still return hijri in ar culture .

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I have tried to add input hidden in my application to add this solution but still return hijri in ar culture .

    Can you share your code?

    DId you use CultureInfo.CurrentUICulture or new CultureInfo()?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Merna created

    Hello , Here is my code ,

       <input hidden
                    type="text"
                    class="form-control"
                    name="testHijriInput"
                    value="@DateTime.Now.AddMonths(-1).Date.ToString(CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern)" />
    

    I have used CultureInfo.CurrentUICulture .

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you consider it like this?

    @if (CultureInfo.CurrentUICulture.TwoLetterISOLanguageName == "ar")
    {
        <input type="text"
               class="form-control"
               name="StartDate"
               value="@DateTime.Now.AddMonths(-1).Date.ToString("Custom your ShortDatePattern")" />
    }
    else
    {
        <input type="text"
               class="form-control"
               name="StartDate"
               value="@DateTime.Now.AddMonths(-1).Date.ToString(CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern)" />
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Merna created

    hello , still hijri date appears

    if (CultureInfo.CurrentUICulture.TwoLetterISOLanguageName == "ar") {

            &lt;input  hidden
                   type=&quot;text&quot;
                   class=&quot;form-control&quot;
                   name=&quot;testHijriInput&quot;
                   value=&quot;@DateTime.Now.AddMonths(-1).Date.ToString(&quot;MM/dd/yyyy&quot;)&quot; /&gt;
        }
        else
        {
            &lt;input hidden
                type=&quot;text&quot;
                class=&quot;form-control&quot;
                name=&quot;testHijriInput&quot;
                value=&quot;@DateTime.Now.AddMonths(-1).Date.ToString(CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern)&quot; /&gt;
             
        }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Merna created

    Hello , I tried to enforce the culture to use en-US and date is Gregorian in arabic .

    Using : <input hidden type="text" class="form-control" name="testHijriInput1" value="@DateTime.Now.AddMonths(-1).Date.ToString(new CultureInfo("en-US"))" />

    so ,is there a way to be more generic to configure it once in the whole application?
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Howt about this way?

    app.UseAbpRequestLocalization();
    app.Use(async (httpContext, next) =>
    {
        if (CultureInfo.CurrentUICulture.TwoLetterISOLanguageName == "ar")
        {
            CultureInfo.CurrentUICulture = new CultureInfo("ar")
            {
                DateTimeFormat =
                {
                    ShortDatePattern = "your custom format",
                    Calendar = new GregorianCalendar()
                    // other properties of DateTimeFormat 
                }
                // other properties of CultureInfo
            };
        }
        await next(httpContext);
    });
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Merna created

    Hello , I tried these configurations ,but unfortunately it doesn't work either.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi Merna

    Can you try to use asp net core without abp?

    https://bootstrap-datepicker.readthedocs.io/en/latest/

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
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.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.