How to get a date displayed in Hebrew calendar with MSFT AJAX library client(Sys namespace)?

I want to display a date with the culture “he-IL” and the Hebrew calendar, but I have not had any success. I’m getting the following:

Expected:
יום שלישי ט”ז אייר תשע”ב

  • How to parse calendar file dates with JavaScript?
  • fullcalendar with clickable popup on hover
  • Javascript Calendar with Drag select for multiple days
  • D3 Calendar View using Associative Array
  • Getting a Jquery selector for month and day only
  • jQuery week calendar plugin
  • Actual:
    יום שלישי 08 שבט 2012

    Just one part of the date is being dispalyed correctly, any ideas why is this happening? Here is one example using C# (It displays the date correctly) and another with Javascript (it does not display the date correctly):

    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" >
    <script type="text/javascript">
        function foo() {
            var d = new Date();
            var p = document.getElementById("txtHebrewDateJS");
            p.value = d.localeFormat(Sys.CultureInfo.CurrentCulture.dateTimeFormat.LongDatePattern);
        }
    </script>
    <asp:Label runat="server" Text="Hebrew calendar, culture he-IL, using code behind" />
    <asp:TextBox runat="server" ID="txtHebrewDate" />
    <br />
    <asp:Label ID="Label1" runat="server" Text="Hebrew calendar, culture he-IL, using asp net ajax" />
    <asp:TextBox runat="server" ClientIDMode="Static" ID="txtHebrewDateJS"  />
    <br />
    <asp:Button runat="server" Text="load hebrew date" onclientclick="foo();" />
    

    Code behind:

    using System;
    using System.Globalization;
    using System.Threading;
    
    public partial class _Default : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
            txtHebrewDate.Text = DateTime.Now.ToString(Thread.CurrentThread.CurrentCulture.DateTimeFormat.LongDatePattern);
        }
    
        protected override void InitializeCulture() { 
            var c = new System.Globalization.CultureInfo("he-IL"); 
            c.DateTimeFormat.Calendar = new HebrewCalendar(); 
            Thread.CurrentThread.CurrentCulture = c; 
            Thread.CurrentThread.CurrentUICulture = c; 
            base.InitializeCulture(); 
        }
    }
    

  • Is there a Scheduler/Calendar JS Widget library?
  • Script only executing on Edit Mode-Sharepoint Page
  • Recommendation for Jquery Calendar plugin with multiple months displayed
  • Creating A Javascript Calendar (Full, not pop up)
  • D3 Calendar View using Associative Array
  • How to parse calendar file dates with JavaScript?
  • One Solution collect form web for “How to get a date displayed in Hebrew calendar with MSFT AJAX library client(Sys namespace)?”

    public string HebrewDate(string dateString)
      {
       DateTime date = DateTime.Parse(dateString);             
    
       var ci = CultureInfo.CreateSpecificCulture("he-IL");
       ci.DateTimeFormat.Calendar = new HebrewCalendar();
       return date.ToString("D", ci);
      }
    

    If you don’t want to display the day of week, You can change line:

    return date.ToString("D", ci);
    

    into:

    return date.ToString("d", ci);
    

    Source: Shimmy’s comment on C# and iOS Programming blog