Search code examples
c#asp.net-mvcmodel-view-controllercalendarhijri

How to pass Georgian date to another method in computer having Hijri calendar My code attached changing format ? MVC


My computer system is in Hijri date calendar system. I want to pass Georgian date to another method but it changes it into a Hijri date. My this method is passing dates,

 function printReport() {
            if (!$scope.SearchReport.$valid) {
                toastr.error(FillAllRequired);
                return;
            }
            window.open(utilitiesService.getFullPath()
                + '//Evaluations/PrintReport?From=' 
                + $scope.searchCriteria.From
                + "&To=" + $scope.searchCriteria.To

            );
        }

Here from date is '2018-03-01' and To date is '2019-03-20'. Method that get these parameter is PrintReport. Method is like,

 public void PrintVisitReport(
            DateTime? From,
            DateTime? To)
                    {
                 .....
                    }

Here I am getting From value '{13/06/39 12:00:00 ص}' and for To '{13/07/40 12:00:00 ص}'

How can I get the same date on this method as computer DateTime system is in Hijri calendar

Hopes for your suggestion. Changing the calendar system is not a choice.


Solution

  • try this Code:

    CultureInfo french = CultureInfo.GetCultureInfo("fr-FR");
    CultureInfo arabic = CultureInfo.GetCultureInfo("ar-AR");
    String nowStr = DateTime.Now.ToString(french);
    string dt = DateTime.Parse(nowStr, french).ToString(arabic);
    Console.WriteLine(" DATE : " + nowStr.ToString());
    Console.WriteLine(" DATE : " + dt.ToString());
    Console.Read();