ayman ayman - 7 months ago 11
Javascript Question

How to change the date range picker's date format?

I am using this bootstrap date range picker. I want to change date format date to

dd/MMM/yyyy
:

<script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap/latest/css/bootstrap.css" />

<!-- Include Date Range Picker -->
<script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>

<script type="text/javascript">
$(function() {
$("#<%= txtName.ClientID %>").daterangepicker();
});
</script>

Answer

You need to add a locale object after you run the daterangepicker function. I can't yet find documentation on what formats it supports, but try this:

$(function() {
    $("#<%= txtName.ClientID %>").daterangepicker({
        locale: {
            format: 'DD/MMM/YYYY'
        }
    });
});

See here for more options: http://www.daterangepicker.com/#config

Comments