Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:19:53+00:00 2026-06-17T21:19:53+00:00

Now i am working with Hijri dates and trying to convert them to Gregorian

  • 0

Now i am working with Hijri dates and trying to convert them to Gregorian dates using the following code :

string HijriDate;
string[] allFormats ={"yyyy/MM/dd","yyyy/M/d",
    "dd/MM/yyyy","d/M/yyyy",
    "dd/M/yyyy","d/MM/yyyy","yyyy-MM-dd",
    "yyyy-M-d","dd-MM-yyyy","d-M-yyyy",
    "dd-M-yyyy","d-MM-yyyy","yyyy MM dd",
    "yyyy M d","dd MM yyyy","d M yyyy",
    "dd M yyyy","d MM yyyy","MM/dd/yyyy"};
CultureInfo enCul = new CultureInfo("en-US");
CultureInfo arCul = new CultureInfo("ar-SA");
arCul.DateTimeFormat.Calendar = new System.Globalization.HijriCalendar(); 
DateTime tempDate = DateTime.ParseExact(HijriDate, allFormats, arCul.DateTimeFormat, DateTimeStyles.AllowWhiteSpaces);
return tempDate.ToString("MM/dd/yyyy");

this code is working fine with all dates except the date that has 30th day in month like the following :

30/10/1433, 30/12/1432 or 30/05/1433 etc. so how to handle and convert that date with its corresponding Gregorian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:19:55+00:00Added an answer on June 17, 2026 at 9:19 pm

    here is the code it is working well
    now on this code I’m returning the date from the function as string not as datetime, but you can simply using return datetime type instead on string

    public string ConvertDateCalendar(DateTime DateConv, string Calendar, string DateLangCulture)
    {
        System.Globalization.DateTimeFormatInfo DTFormat;
        DateLangCulture = DateLangCulture.ToLower();
        /// We can't have the hijri date writen in English. We will get a runtime error - LAITH - 11/13/2005 1:01:45 PM -
    
        if (Calendar == "Hijri" && DateLangCulture.StartsWith("en-"))
        {
            DateLangCulture = "ar-sa";
        }
    
        /// Set the date time format to the given culture - LAITH - 11/13/2005 1:04:22 PM -
        DTFormat = new System.Globalization.CultureInfo(DateLangCulture, false).DateTimeFormat;
    
        /// Set the calendar property of the date time format to the given calendar - LAITH - 11/13/2005 1:04:52 PM -
        switch (Calendar)
        {
            case "Hijri":
                DTFormat.Calendar = new System.Globalization.HijriCalendar();
                break;
    
            case "Gregorian":
                DTFormat.Calendar = new System.Globalization.GregorianCalendar();
                break;
    
            default:
                return "";
        }
    
        /// We format the date structure to whatever we want - LAITH - 11/13/2005 1:05:39 PM -
        DTFormat.ShortDatePattern = "dd/MM/yyyy";
        return (DateConv.Date.ToString("f", DTFormat));
    }
    

    To call this Method here are an example

    ltrCalValue.Text = ConvertDateCalendar(CalHijri.SelectedDate, "Gregorian", "en-US");
    

    To call the Hijri

    ltrCalValue.Text = ConvertDateCalendar(CalHijri.SelectedDate, "Hijri", "en-US");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm now working with code that looks like this public String getName(User user) {
I'm just started working in Titanium. And now working on popover in titanium, using
Thanks to Code Poet, I am now working off of this code to parse
Coming from Eclipse and now working in Visual Studio I was trying to assign
First question here! I'm trying to create a mail system and now working on
I'm using WAMP on windows, which installs PHP, Apache and MySQL. I'm now working
Hey i'm using oracle sql to create a database. I im now working on
OK the code is now working, but it still needs work. The values I
I have now working updatable news using xml, but whenever i refresh the 1st
This is most of my code for my now working python blackjack game (or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.