vuejs-datepicker icon indicating copy to clipboard operation
vuejs-datepicker copied to clipboard

Date picker given data and time one day back ,How to solve that issue

Open tantan-thrymr opened this issue 8 years ago • 9 comments
trafficstars

Date picker given wrong date Date picker subtracting one day please give me solution how to solve that issue ,i don't know about that every functionality is working file except subtracting one day

tantan-thrymr avatar Jun 02 '17 09:06 tantan-thrymr

@tantan-thrymr Did you even bother to look if this issue was already raised?

maxim25 avatar Jun 02 '17 10:06 maxim25

so,I want solution ,

tantan-thrymr avatar Jun 02 '17 11:06 tantan-thrymr

There are solutions offered in the other thread..

maxim25 avatar Jun 02 '17 11:06 maxim25

Likely this has to do with timezone issues/inconsistencies? e.g. if you are setting or getting a historical date stored without a timezone attached, it might default to UTC, which could be different than your local settings and therefore cause a slight difference in reported day/date.

mismith avatar Jun 05 '17 16:06 mismith

Specifically @maxim25 is referencing https://github.com/charliekassel/vuejs-datepicker/issues/23 and https://github.com/charliekassel/vuejs-datepicker/issues/118 I believe.

For me, I just included a timestamp in the string I was parsing/storing.

mismith avatar Jun 06 '17 16:06 mismith

I was experiencing this when I was passing a pure date string "YYYY-MM-DD" as a property into the vue component. It appears that date strings are being parsed as midnight UTC, then being displayed in local system time. Moment.js can correct this behavior if you want to feed it a simple date string:

In my vue component code:

job.scheduled = Moment('2017-06-28', 'YYYY-MM-DD').toDate();

Vue template:

<datepicker v-model="job.scheduled" format="MM/dd/yy" clear-button></datepicker>

I'm sure there are other ways but my project was using Moment anyway.

dpearre avatar Jun 28 '17 19:06 dpearre

I'm working on a little fix for this so far I have it somewhat working with no date currently. BUT it does mess up and go back its normal self when a date is passed in via v-model! 😞

https://github.com/minesh93/vuejs-datepicker

this.selectedDate.setHours(0, -(this.selectedDate.getTimezoneOffset()), 0) inside Datepicker.Vue

I thought negating the timezone could help, need to look into why its not working for dates that are loaded in. Will post updates here.

minesh93 avatar Jun 29 '17 21:06 minesh93

The magic Date.prototype.toJSON = function () { return moment(this).format(); }

ugurozturk avatar Nov 20 '19 14:11 ugurozturk

I had issue where 'available-dates' was displaying off by 1 day. Apparently v-date-picker will default your date list's [dates] to be midnight GMT, so after handling this, I made it work.

pauloconnell avatar Sep 26 '23 20:09 pauloconnell