title: AjaxControlToolkit CalendarExtender - Wrong Date/Time Bug?
body: <p>I am having a problem with the <code>AjaxControlToolkit</code> <code>CalendarExtender</code>. Let me explain my page setup. I have an ASP <code>TextBox</code> on the page that is supposed to hold the End Time of an event. The time must be in the format "MM/dd/yyyy hh:mm:ss tt" (i.e. "11/06/2011 11:59:59 PM"). </p>
  
  <p>Here is what the page layout looks like:</p>
  
  <p>A reference to the <code>AjaxControlToolkit</code> at the top of the page.</p>
  
  <pre><code>&lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" 
               TagPrefix="ajax" %&gt;
  </code></pre>
  
  <p>The relevant body markup of the page:</p>
  
  <pre><code>&lt;asp:Label ID="_lblEventEndTime" runat="server" Text="End Time:" /&gt;
  &lt;asp:TextBox ID="_txtEventEndTime" runat="server" /&gt;  
  &lt;asp:ImageButton ID="_imgbtnEventEndTime" runat="server" 
                   ImageUrl="~/Images/Calendar.png"/&gt;
  &lt;ajax:CalendarExtender ID="_cldrextEndDate" runat="server" 
                         CssClass="CalendarTheme" 
                         PopupButtonID="_imgbtnEventEndTime" 
                         TargetControlID="_txtEventEndTime" 
                         Format="MM/dd/yyyy hh:mm:ss tt" /&gt;   
  </code></pre>
  
  <p>And the C# code behind:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      DateTime nov6 = new DateTime(2011, 11, 6, 23, 59, 59);
      _txtEventEndTime.Text = nov6.ToString("MM/dd/yyyy hh:mm:ss tt");
  }
  </code></pre>
  
  <p>Now for some reason I have only been able to reproduce this bug on <strong>November 6, 2011</strong>. But as you can see in the on Page_Load I am setting the time to "23:59:59" which is "11:59:59 PM". However when the page comes back the textbox says "11/06/2011 <strong>10</strong>:59:59 PM" instead of "11/06/2011 <em>11</em>:59:59 PM"</p>
  
  <p>Now here is where things get weird. If I remove the CalendarExtender from the page everything works fine and the page loads as expected with the correct value in the TextBox. What is also weird is if I change the FormatString of the CalendarExtender to </p>
  
  <pre><code>Format="MMMM/dd/yyyy hh:mm:ss tt" 
  </code></pre>
  
  <p>the page loads with the proper value - the only problem here is now when I actually click my Calendar ImageButton and use the CalendarExtender it will place the DateTime into the TextBox in the format "November/06/2011 12:00:00 AM" (but this is expected).</p>
  
  <p>Now if I change the DateTime in the code behind to</p>
  
  <pre><code>DateTime nov6 = new DateTime(2011, 11, 6, 22, 59, 59);
  </code></pre>
  
  <p>The Textbox will come back as "11/06/2011 <strong>09</strong>:59:59 PM" but it should read "11/06/2011 <em>10</em>:59:59 PM". </p>
  
  <p>What I am perplexed about is why the CalendarExtender is interfering with my TextBox Control. Its almost as if the calendar extender things that hours go from 1-24 instead of 0-23. Is there some sort of bug with the CalendarExtender that I am not aware of?</p>
  
  <p>P.S. - All of these controls are on a test page so there is nothing else interfering with them.</p>