DateTime选择器无法在Web应用中使用

时间:2019-07-10 05:47:47

标签: javascript datetime

我正在尝试将此DateTime Picker添加到我的应用程序中,我不确定为什么。我已经有了使它工作所需的库。.这是我的库,如下:

<!-- jQuery library -->
<script src="js/jquery.min.js"></script>

<!-- Bootstrap library -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="bootstrap/js/bootstrap.min.js"></script>

<link href="css/bootstrap-datetimepicker.css" rel="stylesheet">

这是dateTime选择器的代码

                <label for="dateTime">Date and Time</label>
                <input type="text" name="datetime" id="datetime" class="form-control" readonly>

                <script type="text/javascript">
                    $(function () {
                        var today = new Date();
                        var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
                        var time = today.getHours() + ":" + today.getMinutes();
                        var dateTime = date+' '+time;
                        $("#datetime").datetimepicker({
                            format: 'yyyy-mm-dd hh:ii',
                            autoclose: true,
                            todayBtn: true,
                            startDate: dateTime
                        });
                    });
                </script>

1 个答案:

答案 0 :(得分:0)

包括必要的脚本和样式:

    <head>
  <!-- ... -->
  <script type="text/javascript" src="/bower_components/jquery/jquery.min.js"></script>
  <script type="text/javascript" src="/bower_components/moment/min/moment.min.js"></script>
  <script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="/bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
  <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css" />
  <link rel="stylesheet" href="/bower_components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css" />
</head>