ayman ayman - 2 years ago 96
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


<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();

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download