如何计算两个时间选择器之间的小时数 [英] How to calculate hours between two time pickers
本文介绍了如何计算两个时间选择器之间的小时数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友们,
我需要。如何计算两个时间选择器之间的小时数......任何人都可以帮助我..
< br $>
谢谢和问候,
Vivek .R
Dear Frnds,
I need. how to calculate hours between two time pickers... can anyone help me..
Thanks & Regards,
Vivek .R
推荐答案
您可以从另一个值中减去DateTime值以获取TimeSpan值。这样:
You can subtract a DateTime value from another to get a TimeSpan value. This way:
DateTime d1 = dtPicker1.Value;
DateTime d2 = dtPicker2.Value;
TimeSpan ts = d1 - d2;
double result = ts.TotalHours;
它取决于日期时间选择器您目前正在使用,请查看以下步骤,了解jquery日期时间选择器
1。从http://xdsoft.net下载日期时间选择器/ jqplugins / datetimepicker /
2。将jquery.datetimepicker.js,jquery.js和jquery.datetimepicker.css文件添加到asp.net解决方案并添加链接
it depend on the date time picker you are currently using, check below steps for jquery date time picker
1.Download date time picker from http://xdsoft.net/jqplugins/datetimepicker/
2.Add jquery.datetimepicker.js, jquery.js and jquery.datetimepicker.css files to asp.net solution and add links
<head runat="server">
<title></title>
<link rel="stylesheet" type="text/css" href="./jquery.datetimepicker.css" />
<script type="text/javascript" src="./jquery.js"></script>
<script type="text/javascript" src="./jquery.datetimepicker.js"></script>
</head>
3。为两个日期时间选择器添加两个文本框
3. Add two text box for the two date time pickers
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
4。需要添加javascript来填充日期时间选择器
4. Need to add javascript to populate the date time picker
<script type="text/javascript">
( document )。ready( function (){
(document).ready(function () {
这篇关于如何计算两个时间选择器之间的小时数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文