oliver
oliver

Reputation: 87

How can I use datetimepicker in Laravel 8?

How can I use a datetimepicker knowing that I use bootstrap4 and most of the solutions I found on the internet didn't work well and input type="datetime" feature is no longer supported by most browsers

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" >
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.css" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.26.0/moment.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js"></script>
       

 <input id="id" name="datetime" type="text" class="form-control datetimepicker"  value="">

<script>
$(function () {
             $('.datetimepicker').datetimepicker();
         });
  
      
</script>

Upvotes: 0

Views: 8259

Answers (2)

rootShiv
rootShiv

Reputation: 1417

if you'r looking for better datepicker than basic . I will suggest you to use flatpikr , you can do much more using that like you can pick date between range, format date ,enable or disable certain date, enable or disable given range of date and it has better ui than basic calendar . check out it's examples.

Upvotes: -1

mmh4all
mmh4all

Reputation: 1761

instead of deprecated datetime you can use

<input type="datetime-local">

more details you can find on https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local

Upvotes: 2

Related Questions