title: how to change date from gregorian to shamsi in javascript
body: <p>I want to change date from Gregorian to shamsi in JavaScript. I am reading data from model with ajax so datetime field is Gregorian but I want to display shamsi date to user .and I want to use this shamsi date instead of result.datetime in the code below, but I don't know how to do this.</p>
  
  <pre><code> function f2() {
  
      var ID = $("#sel").val();
     $.ajax({
          url: "/Account/GetPredict",
          data: { ID: ID },
          type: "post",
          success: function (value) {
              res = JSON.parse(value);
              $("#mm").empty();
              $("#mdiv").empty();
              $("#mm").append("&lt;tr&gt;&lt;td align='center'&gt; بازی&lt;/td&gt;&lt;td align='center'&gt;تاریخ&lt;/td&gt;&lt;td align='center'&gt;پیش بینی شما&lt;/td&gt;&lt;td align='center'&gt;امتیاز کسب شده&lt;/td&gt;&lt;/tr&gt;");
              $.each(res, function (idx, result) {
  
                  $("#mm").append("&lt;tr&gt;&lt;td align='center'&gt;" + result.game + "&lt;/td&gt;&lt;td align='center'&gt;" + ToJavaScriptDate(result.datetime) + "&lt;/td&gt;&lt;td align='center'&gt;" + result.predict + "&lt;/td&gt;&lt;td align='center'&gt;" + result.score + "&lt;/td&gt;&lt;/tr&gt;");
  
              })
              if (res!=null) {
                  $("#mdiv").append("&lt;a style='color:red' href='../Account/PdfGenerator?ID=" + ID + "'&gt;&lt;img src='../img/pdf.png' /&gt;&lt;/a&gt;");
              }
          }
      })
  }
  function ToJavaScriptDate(value) {
      alert('ok')
      var pattern = /Date\(([^)]+)\)/;
      var results = pattern.exec(value);
      var dt = new Date(parseFloat(results[1]));
      alert(dt)
      var pc_fa = $.calendars.instance('persian', 'fa');
      var jdate33 = pc_fa.fromJSDate(new Date(dt.getFullYear(), dt.getMonth(), dt.getDate()));
      return jdate33;
  
  }
  
  
  &lt;/script&gt;
  </code></pre>