PrimeVue : Calendar selection goes 1 day in the past

238 Views Asked by At

Getting selectedDate value as 1 day previous of selected date, as Selected 10-11-2023 in selectedDate it is 09-11-2023

<Calendar v-model="selectedDate" showIcon dateFormat="yy-mm-dd" />

I have tried dateFormat="yy-mm-dd"

1

There are 1 best solutions below

0
On

I resolved the issue by making adjustments to the selected date.

Here is the updated usage of the component, along with the event handler:

<Calendar
  v-model="selectedDate"
  showIcon
  dateFormat="yy-mm-dd"
  @date-select="handleDateChange($event)"
/>
const handleDateChange = (newDate) => {
  if (newDate) {
    selectedDate = new Date(newDate.getTime() - newDate.getTimezoneOffset() * 60000);
  }
}