1 Star 0 Fork 14

dizhu/Light Year Admin Using v5 For Example

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
lyear_js_daterangepicker.html 6.02 KB
一键复制 编辑 原始数据 按行查看 历史
笔下光年 提交于 2022-12-10 17:27 . feat:代码上传
<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<meta name="keywords" content="LightYear,LightYearAdmin,光年,后台模板,后台管理系统,光年HTML模板">
<meta name="description" content="Light Year Admin V5是一个基于Bootstrap v5.1.3的后台管理系统的HTML模板。">
<title>时间段选择器Date Range Picker - 光年(Light Year Admin V4)后台管理系统模板</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="stylesheet" type="text/css" href="css/materialdesignicons.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link href="js/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.min.css">
<style>
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<header class="card-header">
<div class="card-title">时间段选择器Date Range Picker</div>
</header>
<div class="card-body">
<p>这里使用的是3.0.5,官方地址:<a href="http://www.daterangepicker.com/" target="_blank">http://www.daterangepicker.com/</a></p>
<div class="mb-3">
<label for="dates" class="form-label">默认使用</label>
<input type="text" id="dates" class="form-control" />
</div>
<div class="mb-3">
<label for="daterange" class="form-label">带回调的简单日期范围选择器</label>
<p class="text-muted">可到控制台查看回调的输出情况。</p>
<input type="text" name="daterange" id="daterange" class="form-control" />
</div>
<div class="mb-3">
<label for="datetimes" class="form-label">日期范围选择器与时间</label>
<input type="text" name="datetimes" id="datetimes" class="form-control" />
</div>
<div class="mb-3">
<label for="birthday" class="form-label">单日期选择器</label>
<input type="text" name="birthday" id="birthday" class="form-control" />
</div>
<div class="mb-3">
<label for="reportrange" class="form-label">预定义的日期范围</label>
<div class="input-group">
<input type="text" id="reportrange" class="form-control" value="" />
<span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
</div>
</div>
<div class="mb-3">
<label>输入最初为空</label>
<input type="text" name="datefilter" class="form-control" />
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/popper.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/main.min.js"></script>
<script type="text/javascript" src="js/momentjs/moment.min.js"></script>
<script type="text/javascript" src="js/momentjs/locale/zh-cn.min.js"></script>
<script type="text/javascript" src="js/bootstrap-daterangepicker/daterangepicker.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// 入门使用
$('#dates').daterangepicker({
startDate: moment(),
endDate: moment().add(2, 'day')
});
// 带回调的处理
$('input[name="daterange"]').daterangepicker({
opens: 'left'
}, function(start, end, label) {
console.log("您选择的时间段是:" + start.format('YYYY-MM-DD') + '' + end.format('YYYY-MM-DD'));
});
// 日期范围选择器与时间
$('input[name="datetimes"]').daterangepicker({
timePicker: true,
startDate: moment().startOf('hour'),
endDate: moment().startOf('hour').add(32, 'hour'),
locale: {
format: 'M/DD hh:mm A'
}
});
// 单日期选择器
$('input[name="birthday"]').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
minYear: 1901,
maxYear: parseInt(moment().format('YYYY'),10)
}, function(start, end, label) {
var years = moment().diff(start, 'years');
alert("您已经 " + years + " 岁了。");
});
// 预定义的日期范围
var start = moment().subtract(29, 'days');
var end = moment();
function cb(start, end) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
}
$('#reportrange').daterangepicker({
startDate: start,
endDate: end,
ranges: {
'今天': [moment(), moment()],
'昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'七天前': [moment().subtract(6, 'days'), moment()],
'30天前': [moment().subtract(29, 'days'), moment()],
'当前月': [moment().startOf('month'), moment().endOf('month')],
'上个月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
}
}, cb);
cb(start, end);
// 输入最初为空
$('input[name="datefilter"]').daterangepicker({
autoUpdateInput: false,
locale: {
cancelLabel: '清空'
}
});
$('input[name="datefilter"]').on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
});
$('input[name="datefilter"]').on('cancel.daterangepicker', function(ev, picker) {
$(this).val('');
});
});
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/johnnyhg/light-year-admin-using-v5-for-example.git
git@gitee.com:johnnyhg/light-year-admin-using-v5-for-example.git
johnnyhg
light-year-admin-using-v5-for-example
Light Year Admin Using v5 For Example
master

搜索帮助