stefangabos / Zebra_Datepicker

A super-lightweight, highly configurable, cross-browser date time picker jQuery plugin
https://stefangabos.github.io/Zebra_Datepicker/
Other
399 stars 183 forks source link

Alternative format for post #149

Closed liedekef closed 5 years ago

liedekef commented 5 years ago

Hi,

this seems like a promising project, but is there an alternative format-field option to change the format of the form post field?

Franky

stefangabos commented 5 years ago

https://github.com/stefangabos/Zebra_Datepicker#user-content-format

liedekef commented 5 years ago

That option changes both the format in the frontend and in the backend, while I'm searching for a method that shows one format in the frontend and submits in another format.

stefangabos commented 5 years ago

This is front-end only and has nothing to do with the back-end - that's all yours to build to your likings

stefangabos commented 5 years ago

...you could, for example, use the onSelect event to populate a hidden field with any format you want and then use that on the backend

zeve-zz commented 5 years ago

@stefangabos but how do you pass that changed format to anywhere? the only date object that i can access within the onselect is the one that is already formatted. and then if i try to pass that into a date object with javascript i get an "invalid date" output.

liedekef commented 5 years ago

While I'd love to use Zebra_Datepicker, I couldn't wait for this implementation, so I based myself of another datepicker and made it work the way I like it (and I think it can benefit a lot of people). So feel free to check out my fdatepicker repo (out of respect for the people working hard on this project, I won't directly link to mine).

stefangabos commented 5 years ago

@zeve-zz the function attached to onSelect takes 3 arguments. see the documentation

stefangabos commented 5 years ago

here, I made you an example

zeve-zz commented 5 years ago

@stefangabos ive seen you link the documentation on this issue 3 times but people still have the same question :)

i think you should update the documentation to state:

The callback function takes 3 arguments:

"formatted": the date in the format specified by the format attribute "yyyymmdd": the date in YYYY-MM-DD format and additionally hours, minutes and seconds if time picker is enabled "jsobject": the date as a JavaScript Date object

stefangabos commented 5 years ago

i think it is pretty clear: the function takes 3 arguments. just name them a, b & c and do a console.log() on them if the docs are not clear. i'll think about it - thank you for the heads up!