Search code examples
momentjspikaday

Pikaday format does not work despite including moment.js


I am using the Pikaday Data Picker. I am unable to override the default format to MM/DD/YYYY. I have included the Pikaday library and Moment.js but it still does not work.

<input id="datepicker" type="text" />

    var picker = new Pikaday(
    {
        field: document.getElementById('datepicker'),
        format : "MM/DD/YYYY",
        firstDay: 1,
        minDate: new Date('2000-01-01'),
        maxDate: new Date(),
        yearRange: [2000,2020]      
    });

Here is my fiddle:
http://jsfiddle.net/gfinzer/t046bqm2/2/


Solution

  • You are including moment.js after Pikaday — it needs to be the other way around.

    <script type="application/javascript" src="moment.js"></script>
    <script type="application/javascript" src="pikaday.js"></script>
    

    (this code block is only here, because SO otherwise won't let me post the link to JSFiddle without it)

    Updated example: http://jsfiddle.net/janfoeh/t046bqm2/3/