jmv
jmv

Reputation: 415

easy to use Date time picker

I'm looking for an easy to use date time picker. I tried to use bootstrap date time picker and I'm using bootstrap 4 alpha. It does not work for me.

Here is my code:

    <script>
    $(function() {
        $('#datetimepicker1').datetimepicker();
    });
    </script>
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
   <!-- Moment JS -->
    <script type="text/javascript" src="<?php echo $ROOT; ?>js/moment.min.js"></script>
    <!--Bootstrap JS -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" ></script>
    <!-- dateTimePicker JS -->
    <script type="text/javascript" src="<?php echo $ROOT; ?>js/bootstrap-datetimepicker.min.js"></script>
    <!--bootstrap  -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
    <!-- dateTimePicker CSS -->
    <link rel="stylesheet" type="text/css" href="<?php echo $ROOT; ?>css/bootstrap-datetimepicker.min.css"> 

    <div class = "form-group col col-md-4 col-sm-4 col-12">
        <div class='input-group date' id='datetimepicker1'>
          <input type='text' class="form-control" id="servDate"/>
          <span class="input-group-addon">
            <span class="glyphicon glyphicon-calendar"></span>
          </span>
        </div>
    </div>

Upvotes: 1

Views: 3642

Answers (3)

beaver
beaver

Reputation: 17647

I suggest to use: https://tempusdominus.github.io/bootstrap-4/ which is the Bootstrap 4 version of DateTimePicker (successor of Eonasdan/bootstrap-datetimepicker).

You can find examples in the documentation: https://tempusdominus.github.io/bootstrap-4/Usage/

Github repo: https://github.com/tempusdominus/bootstrap-4

However here is a working snippet from tempusdominus docs (best view expanding snippet):

$(function () {
    $('#datetimepicker1').datetimepicker();
});
<script src="https://npmcdn.com/[email protected]/dist/js/tether.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css" crossorigin="anonymous">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.0/moment-with-locales.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<script src="https://rawgit.com/tempusdominus/bootstrap-4/master/build/js/tempusdominus-bootstrap-4.min.js"></script>
<link href="https://rawgit.com/tempusdominus/bootstrap-4/master/build/css/tempusdominus-bootstrap-4.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">


<div class="container">
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <div class="input-group date" id="datetimepicker1" data-target-input="nearest">
                    <input type="text" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
                    <span class="input-group-addon" data-target="#datetimepicker1" data-toggle="datetimepicker">
                        <span class="fa fa-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
    </div>
</div>

Upvotes: 2

Ivisivel
Ivisivel

Reputation: 29

Use stable library, may be you doesn't know where is bug in beta version ;) Try this

<script type="text/javascript" src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<!-- Moment JS -->
<script type="text/javascript" src="//momentjs.com/downloads/moment.js"></script>
<!--Bootstrap JS -->
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<!-- dateTimePicker JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<!-- bootstrap  -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" />
<!-- dateTimePicker CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
<script>
$(function() {
    $('#datetimepicker1').datetimepicker();
});
</script>
<div class = "form-group col col-md-4 col-sm-4 col-12">
    <div class='input-group date' id='datetimepicker1'>
        <input type='text' class="form-control" id="servDate"/>
        <span class="input-group-addon">
            <span class="glyphicon glyphicon-calendar"></span>
        </span>
    </div>
</div>

Might be a little help ^_^

Upvotes: 0

not_null
not_null

Reputation: 111

Try to use Bootstrap 3. Found some helpful link: https://eonasdan.github.io/bootstrap-datetimepicker/ Hope this helps.

Upvotes: -1

Related Questions