2021/09/05 bootstrap 日期时间戳 datetimepicker

–背景:使用CDN引入

–控件效果(可选时分秒)
2021/09/05 bootstrap 日期时间戳 datetimepicker

–代码
html

<div class="container">
                    <div class="row">
                        <div class='col-sm-2'>
                            <div class="form-group">
                                <div class='input-group date' id='datetimepicker1'>
                                    <input type='text' class="form-control"/>
                                    <span class="input-group-addon">
                                        <span class="glyphicon glyphicon-calendar"></span>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
</div>

js

<script src="https://cdn.bootcss.com/moment.js/2.18.1/moment-with-locales.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>

//写在方法里面
$('#datetimepicker1').datetimepicker();//初始化datetimepicker控件

获取控件选中的时间值(参考最后的参考链接2)

//获取datetimepicker数据
var datetime1 = $('#datetimepicker1').data().date;//没有数据时undefined
  // console.log('datetime1------------', datetime1);

var datetimestamp = Date.parse(datetime1).toString();//毫秒时间戳
  // console.log('datetimestamp------', datetimestamp);

var dts = datetimestamp.substr(0, datetimestamp.length - 3);//秒时间戳
  // console.log('dts', dts);

–参考链接
1.datatimepick效果demo
2.通过控件获取时间戳
3.获取起始时间戳

上一篇:D1哪吒开发板wifi连接出错,这是什么情况?


下一篇:MHA0.58依赖包