Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How accurate is the HTMLbootstrap time selector control accurate to seconds datetimepicker controls to seconds?


May 29, 2021 Article blog



When using the bootstrap datetimepicker selector control in HTML, you will find that the plug-in cannot be accurate to seconds, so can the bootstrap time selector control be accurate to seconds?

 How accurate is the HTMLbootstrap time selector control accurate to seconds datetimepicker controls to seconds?1

In fact, you can make simple changes, the original can only choose the year and day, now you can choose the year and day minutes and seconds, the code is as follows:

<html>

    <title>bootstrap-datetimepicker</title>

    <link rel="stylesheet" type="text/css" href="bootstrap.min.css">

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

    <script type="text/javascript" src="jquery.min.js"></script>

    <script type="text/javascript" src="bootstrap.min.js"></script>

    <script type="text/javascript" src="bootstrap-datetimepicker.min.js"></script>

    <script type="text/javascript" src="bootstrap-datetimepicker.zh-CN.js"></script>

    <body>

        <label>选择时间</label>

        <input type="text" id="begin_date" readonly placeholder="点击选择时间" value="">

        <script type="text/javascript">

            var utils = {

                bindTimePicker: function ($controls, opt) {

                    $controls.each(function (i, e) {

                        var $control = $(e),

                            options = $.extend({

                                language:  'zh-CN',

                                autoclose: true,

                                format: "yyyy-mm-dd hh:ii:ss"

                            }, opt);

                        $control.datetimepicker(options);

                    });

                },

            }

            utils.bindTimePicker($("#begin_date, #end_date"), {format: "yyyy-mm-dd hh:ii:ss"});

            $("#begin_date").datetimepicker().on("changeDate", refreshDate);

            var refreshDate = function () {

                var start = $("#begin_date").val();

                $("#end_date").datetimepicker("setStartDate", start);

            };

        </script>

    </body>

</html>

See here want to solve the datetimepicker control how accurate to seconds of friends, have you got the answer you want? There are other things you want to learn that you can find in the HTML column yourself.