TimeSelector仅检测PM而不是Am

时间:2014-11-27 05:22:48

标签: c# time

我有一个数据库表,其中包含两列time1和time2.Time1包含08:00 (08:00:00.000),time2包含17:30(17:30:00.000)。Time1和Time2数据库字段的数据类型为datetime我有像

这样的代码
protected void txtdate_TextChanged(object sender, EventArgs e)
    {


        DateTime time1 = DateTime.ParseExact(txtdate.Text,"dd-MM-yyyy",CultureInfo.InvariantCulture);
        string time4 = time1.ToString("yyyy-MM-dd");
        str = "select TimeIn,TimeOut from MusterRoll where EmpCode='" + ddcode.SelectedItem.Text + "' and Date='"+time4+"'";
        dr = conn.query(str);
        if (dr.Read())
        {
            DateTime time = dr.GetDateTime(0);
            TimeSelector1.SetTime(time.Hour, time.Minute, TimeSelector1.AmPm);
            DateTime time2 = dr.GetDateTime(1);
            TimeSelector2.SetTime(time2.Hour, time2.Minute, TimeSelector2.AmPm);
        }

    }

代码正常工作,但我的TimeSelector1显示20:00而不是08:00 Time2显示正确的17:30时间。这段代码如何只检测PM?我的timeSelector1源ocde是

 <tr>
      <td align="left" class="style2">
      Punch I</td>
      <td align="left">
     <asp:UpdatePanel ID="UpdatePanel5" runat="server">
     <ContentTemplate>
     <div class="input-prepend" title="Update Punch I" data-rel="tooltip">
     <cc1:timeselector ID="TimeSelector1" runat="server" DisplaySeconds="False" 
      SelectedTimeFormat="TwentyFour">
     </cc1:timeselector>
     </ContentTemplate>
     </asp:UpdatePanel>
     </td>
  </tr>

0 个答案:

没有答案