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. 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. Need to add javascript to populate the date time picker
<script type="text/javascript">
$(document).ready(function () {
$('#TextBox1').datetimepicker();
$('#TextBox1').datetimepicker({ value: '2015/04/15 05:03', step: 10 });
$('#TextBox2').datetimepicker();
$('#TextBox2').datetimepicker({ value: '2015/04/15 05:03', step: 10 });
});
</script>
5. you can set default date time from server side(page load) like below
TextBox1.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm");
TextBox2.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm");
6. date time value can be converted to DateTime as below (on button click)
DateTime datetime1;
DateTime datetime2;
if (DateTime.TryParseExact(TextBox1.Text, "yyyy/MM/dd HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out datetime1) && DateTime.TryParseExact(TextBox2.Text, "yyyy/MM/dd HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out datetime2))
{
var hours = datetime2.Subtract(datetime1).TotalHours;
}
Sample project can be downloaded from below link
DateTimePicker Sample VS2008 Web Application.zip[
^]