求时间差(天数)

<script type="text/javascript" language="javascript">

function diffdate() { var syearItem=document.getElementById( "drop_sYear").selectedIndex.toString(); var smonthItem=document.getElementById("drop_sMonth").selectedIndex.toString(); var sdayItem = document.getElementById("drop_sDay").selectedIndex.toString(); var shourItem = document.getElementById("drop_sHour").selectedIndex.toString(); var eyearItem=document.getElementById( "drop_eYear").selectedIndex.toString(); var emonthItem=document.getElementById("drop_eMonth").selectedIndex.toString(); var edayItem = document.getElementById("drop_eDay").selectedIndex.toString(); var ehourItem = document.getElementById("drop_eHour").selectedIndex.toString(); var startdate=new Date(syearItem,smonthItem,sdayItem,shourItem,"0","00"); var enddate=new Date(eyearItem,emonthItem,edayItem,ehourItem,"0","00"); var diff=((enddate.valueOf()-startdate.valueOf())/(1000*3600*24)); var days = Math.ceil(parseInt(diff))+1; document.getElementById("tb_CostDays").value = days; }

</script>

 

  <tr>
               <td class="style5">预计出差<br />
                   时间</td>
               <td colspan="4" class="style2">
                   <asp:DropDownList
                       ID="drop_sYear" runat="server" Height="16px" Width="62px"
                       AutoPostBack="True">
                   </asp:DropDownList>
                   年<asp:DropDownList ID="drop_sMonth" runat="server" Height="16px" Width="62px"
                       AutoPostBack="True" onselectedindexchanged="drop_sMonth_SelectedIndexChanged">
                   </asp:DropDownList>
                   月<asp:DropDownList ID="drop_sDay" runat="server" Height="16px" Width="62px">
                   </asp:DropDownList>
                   日<asp:DropDownList ID="drop_sHour" runat="server" Height="16px" Width="62px">
                   </asp:DropDownList>
                   时<br />
                   至<asp:DropDownList
                       ID="drop_eYear" runat="server" Height="16px" Width="62px">
                   </asp:DropDownList>
                   年<asp:DropDownList ID="drop_eMonth" runat="server" Height="16px" Width="62px"
                       AutoPostBack="True" onselectedindexchanged="drop_eMonth_SelectedIndexChanged">
                   </asp:DropDownList>
                   月<asp:DropDownList ID="drop_eDay" runat="server" Height="16px" Width="62px">
                   </asp:DropDownList>
                   日<asp:DropDownList ID="drop_eHour" runat="server" Height="16px" Width="62px">
                   </asp:DropDownList>
                   时</td>
               <td class="style2">共<asp:TextBox ID="tb_CostDays" runat="server" Width="62px"
                οnfοcus="return diffdate();" />
                   日</td>
             </tr>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值