Date picker choosing wrong date since leap year


#1

I’m using autoform for user-entered events in a date field

"days.$.day": {type:"date",autoform:{type:"date"}}

The date picker is interpreting incorrect dates. For example, if a user enters 3/19/2016 from the date picker, it’s being stored as 3/18/2016, presumably because of a leap year problem? I’m trying to add a different date picker, but not having much luck (my dates are stored in an array which is complicating things). Any help/advice/fix appreciated.


#2

This sounds like a timezone issue. Your date is being stored in Mongo in UTC, so you need to take that into consideration when storing/retrieving/displaying the date.

This might help:

See Model Time Data from more info on how Mongo handles dates/times.


#3

Thank you for the information. My date is wrong before it gets stored in Mongo. If I immediately console.log the form entry, it displays the day previous. I suspect I have the issue mentioned here:

But their fix didn’t work for me. The pickadate datepicker works, but I can’t get the modal to display, unless I make the whole form modal with {{>afModal}}, but then I can’t seem to use a meteormethod for the submit. I’m going to walk away for a bit, I think.


#4

I know this is an old post, but I recently had to abandon my modal datepicker and this problem resurfaced, and your link fixed it. Just added .utc in the following: moment.utc(newDay);

Just wanted to say you were right, and thanks again.