1
votes

I am using V-Date-Picker in vuetify. I am showing multiple dates in date picker. The shown dates were passed from application. But the date picker is showing wrong date format.

 let date = new Date(), context = this.$store.state[this.parentName], date_array=[];
 date=  moment(date).format(context.defaultDateFormat);
 let monthStart = moment(date).startOf('Month').format(context.defaultDateFormat);
                date_array.push(monthStart);
                date_array.push(date);
                let format_date = [];
               format_date.push(moment(monthStart).format('YYYY-MM-DD'));
                format_date.push(moment(date).format('YYYY-MM-DD'));
                this.$store.state[this.parentName].fields.filter(x => x.value == this.fieldName).find(x => x).date = format_date.toString();
                this.$store.state[this.parentName].editedItem.Date = date_array.toString();
                context.picker = format_date.toString();

Please help me out

Correct_format

Date_multiple

Calendar

1

1 Answers

0
votes

Please check by using https://github.com/date-fns/date-fns for formatting the date

Install

npm i date-fns

Usage

import format from 'date-fns/format'
import parseISO from 'date-fns/parseISO'

your v-model variable=format(parseISO(date from variable),'yyyy-MM-dd')

Formatting options are available on https://date-fns.org