Pikaday calendar date format not working

I'm using the Pikaday calendar library, but the date format seems to be ignored. I have this code:

<script>
var picker = new Pikaday(
{
    field: document.getElementById('dayDate'),
    firstDay: 1,
    minDate: new Date(2017, 0, 1),
    maxDate: new Date(2020, 12, 31),
    yearRange: [2017, 2020],
    format: 'YYYY-MM-DD',
    bound: false,
    container: document.getElementById('date-container'),
});
</script>

      

This outputs the date in this format 'Thu May 25 2017' I need it to be in the format '2017-05-25'. What am I doing wrong?

+3


source to share


1 answer


Based on the Pikaday documentation, you should link to Moments.js to customize custom date formatting.

From the docs :



Format

: default output format for .toString () and field value (requires Moment.js for custom formatting)

Be sure to refer to the Moments.js library prior to Pikaday.

+2


source







All Articles