温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

bootstrap datetimepicker 时间控件的使用

发布时间:2020-06-09 23:59:42 来源:网络 阅读:4277 作者:gao_shao_liang 栏目:web开发

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="static/bootstrap-datetimepicker-master/sample-in-bootstrap-v2/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="static/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">


<script type="text/javascript" src="static/bootstrap-datetimepicker-master/sample-in-bootstrap-v2/jquery/jquery-1.8.3.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="static/bootstrap-datetimepicker-master/sample-in-bootstrap-v2/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="static/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="static/bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>


</style>


<script type="text/javascript">
$(document).ready(function() {
$('.form_date').datetimepicker({
format : 'yyyy-mm-dd',
language : 'zh-CN',
weekStart : 1,
todayBtn : 1,
autoclose : 1,
todayHighlight : 1,
startView : 2,
minView : 2,
forceParse : 0
});


var now = new Date();
var nowStr = formatDate(now);
$("#startDate").val(nowStr);

$("#endDate").val(nowStr);

});


function getDatetime() {
var startDate = $("#startDate").val();
var endDate = $("#endDate").val();
alert("startDate=" + startDate + ", endDate=" + endDate);
}


function formatDate(date) {
//var day = new Date(); 
var Year = 0;
var Month = 0;
var Day = 0;
var CurrentDate = "";
//初始化时间 
//Year= day.getYear();//有火狐下2008年显示108的bug 
Year = date.getFullYear();//ie火狐下都可


以 
Month = date.getMonth() + 1;
Day = date.getDate();
//Hour = day.getHours(); 
// Minute = day.getMinutes(); 
// Second = day.getSeconds(); 
CurrentDate += Year + "-";
if (Month >= 10) {
CurrentDate += Month + "-";
} else {
CurrentDate += "0" + Month + "-";
}
if (Day >= 10) {
CurrentDate += Day;
} else {
CurrentDate += "0" + Day;
}
return CurrentDate;
}
</script>

</head>
<body>




<div >
<div class="control-group"
>
<label class="control-label">起始时间:</label>
<div class="controls input-append date form_date" data-date=""
data-date-format="dd MM yyyy" data-link-field="dtp_input2"
data-link-format="yyyy-mm-dd">
<input id="startDate" size="16" type="text"
value="" readonly> <span class="add-on"><i
class="icon-remove"></i></span> <span class="add-on"><i
class="icon-th"></i></span>
</div>


</div>


<div class="control-group"
>
<label class="control-label">结束时间:</label>
<div class="controls input-append date form_date" data-date=""
data-date-format="dd MM yyyy" data-link-field="dtp_input2"
data-link-format="yyyy-mm-dd">
<input id="endDate" size="16" type="text"
value="" readonly> <span class="add-on"><i
class="icon-remove"></i></span> <span class="add-on"><i
class="icon-th"></i></span>
</div>


</div>


<input type="button"  value="时间">
</div>

</body>
<html>


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI