Сообщение от alexgrenn
|
Пробовал всевозможные timepicker
|
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/eggplant/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="http://trentrichardson.com/examples/timepicker/jquery-ui-timepicker-addon.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.0/jquery-ui.min.js"></script>
<script src="http://trentrichardson.com/examples/timepicker/jquery-ui-timepicker-addon.js"></script>
<script>
$(function() {
var startTimeTextBox = $('#inp1');
var endTimeTextBox = $('#inp2');
var showTimeTextBox = $('#inp3');
$.timepicker.timeRange(
startTimeTextBox,
endTimeTextBox, {
onClose: function(dateText, inst) {
if (endTimeTextBox.val() && startTimeTextBox.val()) {
var run = startTimeTextBox.datetimepicker('getDate');
var end = endTimeTextBox.datetimepicker('getDate');
var lunch = [(new Date()).setHours(12, 0, 0, 0), (new Date()).setHours(12, 45, 0, 0)];
run > lunch[0] && (lunch[0] = run);
end < lunch[1] && (lunch[1] = end);
var time = (lunch[1] - lunch[0]) / 60000;
if (run > lunch[1] || end < lunch[0] || run > end) time = 0;
showTimeTextBox.val(time);
}
},
minInterval: (1000 * 60 * 60), // 1hr
timeFormat: 'HH:mm',
start: {}, // start picker options
end: {} // end picker options
}
);
});
</script>
</head>
<body>
<input type="text" id="inp1">
<input type="text" id="inp2">
<input type="text" id="inp3">
</body>
</html>