Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hellicious's avatar

need help with datepicker

im new to laravel and ive been trying to figure out how to add datepicker in laravel, i did google it but i cant seemto find a hood answer or maybe im just too dumb so if anyone know how to please share kindly

0 likes
8 replies
Lalit's avatar

Add date picker Js file in public Js folder

hellicious's avatar

i did add the datepicker file into public folder and put the code into my layout.blade.php this is how my layout.blade.php looks like :

    <!-- Bootstrap -->
    <link rel="stylesheet" href="{{ asset('/css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="{{ asset('/css/font-awesome.min.css') }}">
    <link rel="stylesheet" href="{{ asset('/css/datepicker3.css') }}">
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="{{ asset('/js/bootstrap.min.js') }}"></script>
    <script src="{{ asset('js/bootstrap-datepicker.js') }}"></script>

and also put this colde in my create.blade.php but it didnt work

  <script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
{!! Form::text('date', '', array('id' => 'datepicker','class' => 'form-control')) !!}
jlrdw's avatar

Make sure field has an id such as

<label>odate</label><input type="text" name="odate" id="odate" />

then

 $(document).ready(function () {

        $("#odate").datepicker({
            showOn: "button",
            buttonImage: "/crudv22/public/overcast/images/calendar19.gif",
            buttonImageOnly: true,
            dateFormat: "yy-mm-dd",
            changeMonth: true,
            changeYear: true
        });
    });

something like that. There are examples on the jquery ui site.

hellicious's avatar

where do i put this code? bc i dont think i have this kinda of language in my project, sorry im still new

 $(document).ready(function () {

        $("#odate").datepicker({
            showOn: "button",
            buttonImage: "/crudv22/public/overcast/images/calendar19.gif",
            buttonImageOnly: true,
            dateFormat: "yy-mm-dd",
            changeMonth: true,
            changeYear: true
        });
    });
jlrdw's avatar

where do i put this code?

Bottom of view where the datepicker is needed. You haven't watched any youtube videos on using jquery datepicker, they are free.

Please or to participate in this conversation.