bootstrap-datetimepicker取出时间戳

官方中文地址:http://www.bootcss.com/p/bootstrap-datetimepicker/index.htm


示例代码:
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="{{ url_for("static",filename="bootstrap/css/bootstrap.min.css") }}" rel="stylesheet" media="screen">
    <link href="{{ url_for("static",filename="bootstrap-datetimepicker.min.css") }}" rel="stylesheet" media="screen">
</head>
<body>
<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript" src="{{ url_for("static",filename="bootstrap/js/bootstrap.min.js") }}"></script>
<script type="text/javascript" src="{{ url_for("static",filename="bootstrap-datetimepicker.js") }}" charset="UTF-8"></script>
<script type="text/javascript" src="{{ url_for("static",filename="moment.js") }}"></script>
        <div class="row" id="timepickzone">
            <div class='col-sm-6'>
                <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 class='col-sm-6'>
                <div class="form-group">
                    <div class='input-group date' id='datetimepicker2'>
                        <input type='text' class="form-control" />
                        <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                        </span>
                    </div>
                </div>
            </div>
        </div>
<input type="button" class="query"  value="点击">
    <script type="text/javascript">
            $(function () {
                $('#datetimepicker1').datetimepicker({locale: 'zh-cn',autoclose:true});
                $('#datetimepicker2').datetimepicker({locale: 'zh-cn',autoclose:true});
                $('.query').click(function(){
                    //取出时间戳
                    var datetime1 =$('#datetimepicker1').data().date;
                    var datetimestamp = Date.parse(datetime1).toString();
                    var dts = datetimestamp.substr(0,datetimestamp.length-3);

                    console.log(dts);
                });
            });
        </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值