Change Date Format on jQuery UI Date Picker

I have been trying to format the datepicker so that the date comes out like this:

Jul 23 15

I have been reading this question jQuery UI DatePicker – Change Date Format

But for some reason it is not working for me. I am still learning jQuery so any help on this would be greatly appreciated.

My code is below:

              $('input').datepicker({  
                
                          onSelect: function(dateText, inst) { 
                            var date = $(this).datepicker('getDate'),
                                day  = date.getDate(),  
                                month = date.getMonth() + 1,              
                                year =  date.getFullYear();
                            
                            var parent_div = $(this).closest(".clickable-text");
                            console.log(parent_div);
                            $(".Jquery_day", parent_div).html(day);
                            $(".Jquery_month", parent_div).html(month);
                            $(".Jquery_year", parent_div).html(year); 
                            $(parent_div).addClass("is_selected");   
                            


                        } 
                    });

                    $(window).load(function() {

                    $('input').datepicker();
                    $('input').datepicker("setDate", new Date());

                   var dateFormat = $('input').datepicker({dateFormat: "M-d-y"}).val();

                    });  
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>


Source: jquery

Leave a Reply