vuejs-datepicker
vuejs-datepicker copied to clipboard
Date picker given data and time one day back ,How to solve that issue
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 Did you even bother to look if this issue was already raised?
so,I want solution ,
There are solutions offered in the other thread..
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.
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.
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.
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.
The magic Date.prototype.toJSON = function () { return moment(this).format(); }
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.