Search code examples
vue.jsdatepickermomentjsantdv

Invalid Date with moment js in a date picker


I try to display a date in a date picker (use AntDesign with VueJS) :

this.formDates.test = moment(this.$store.state.dataStudy.startPassation).format('DD-MM-YYYY HH:mm')

When I do this I have my date with the correct format :

console.log(this.formDates.test) // display the correct format 05-07-2021 12:00

But when I do this :

<a-date-picker :default-value="formDates.test" v-model="formDates.startPassation" /><!-- display Invalid Date-->

I have "Invalid Date" in my date picker :-(

Why ?


Solution

  • From documentation I see that is possible to set :default-value with a moment object.

    <a-date-picker :defaultValue="moment('2015-01-01', 'YYYY-MM-DD')" />
    

    try to remove .format('DD-MM-YYYY HH:mm')