How to convert a Persian date into a Gregorian date?

前端 未结 9 1279
萌比男神i
萌比男神i 2020-12-30 04:30

I use the function below to convert Gregorian dates to Persian dates, but I\'ve been unable to write a function to do the reverse conversion. I want a function that converts

9条回答
  •  半阙折子戏
    2020-12-30 05:21

    Using Persia.NET Core can be of help to you:

    Converting Gregorian to Shamsi

    Persia.SolarDate solarDate = Persia.Calendar.ConvertToPersian(DateTime.Now);
    // getting the simple format of persian date
    string str = solarDate.ToString();
    

    Converting Shamsi to Gregorian

    DateTime ConvertToGregorian(SolarDate solarDate)
    DateTime ConvertToGregorian(LunarDate lunarDate)
    DateTime ConvertToGregorian(int year, int month, int day, DateType dateType)
    DateTime ConvertToGregorian(int year, int month, int day, int hour, int minute, int
    second, DateType dateType)
    

    You can download it here If your application is not supported .NET Core you can find the older version of this from NuGet.

提交回复
热议问题