<script type="text/javascript" src="/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">
$(function () {
var $startCreateDate = $(‘#StartDate‘), $endCreateDate = $(‘#EndDate‘);
$startCreateDate.datetimepicker({
format: ‘yyyy-mm-dd‘,
language: ‘zh-CN‘,
autoclose: true,
minView: 2
});
$endCreateDate.datetimepicker({
format: ‘yyyy-mm-dd‘,
language: ‘zh-CN‘,
autoclose: true,
minView: 2
});
window.dateValidation = function () {
var validate = dateComparison($startCreateDate.val(), $endCreateDate.val());
if (!validate) {
alert(‘结束时间必须晚于开始时间!‘);
}
return validate;
}
});
</script>
dateTimePicker怎么取值?
关键看你需要取什么值,比如要取一个年月日的日期值:dateTimePicker1.Value.Date.ToLongDateString();仅仅取一个年、月、日的值:dateTimePicker1.Value.Year.ToString(); dateTimePicker1.Value.Month.ToString();dateTimePicker1.Value.Day.ToString();甚至小时、分、秒都可以,将Value后的属性year修改为.TimeOfDay.Hours等 效果图: