-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: Separate store and display formats support. #1168
Comments
👍 We were looking to use this as a drop-in polyfill for the native |
there's an option for extraFormats which allows users to input d/t without being so strict. You could also listen for the change event and format that value to however you need it. |
With I'm looking for a Right now we would have to do this with a hidden input that is sent to the server, but this breaks our original plan of using this only for when the browser didn't support the native |
Yes, exactly, it's just separating localized/displayed (which is different from country to country) date format from internal date format (which is database specific). Of course this can be worked around either by reformatting the date on the client or on the server, but this is very inconvenient. |
so again, if you had |
No difference, just shortcut method. |
It's important to note that bootstrap-datetimepicker isn't always used in a JS-only environment, where the data is retrieved from the form ahead of time and sent to the server outside of the standard HTML form submission flow. Sometimes the data is actually sent to the server through a form submission, which is where I think this becomes important.
Right now, even when using the The difference here is that the server would be receiving a specific format, possibly different from the format displayed to the user. In order to do this right now one would have to hook into the |
Yes, that's how I'm doing it now, I hook in on the |
I had already tried with extraFormats, but doesn't work! Here my Option: $('.datepicker').datetimepicker({ MY HTTP-POST REGUEST myArray[von]:2015-06-25 23:00 <-- why? If extraFormats would have worked, would have to request it to be so: myArray[von]:25.06.2015 23:00 Yeah, well, what's wrong? |
@Fruchtgummi @afanasy it wouldn't be a shortcut method, you'd just be looking for a different function name @kevin-brown I use this picker in my .Net MVC apps all the time. You'll have to hook into the submit event, set the primary format to the way you need it to be server side, or you'll have to convert it server side to the format you need. You're asking me to force a hook into a form submit event. I don't know what else to tell you. |
There should be another way, other than hooking in the form submit. |
I was looking for the same requested feature and found this thread. Here's the use case for us. We store all dates in ISO format. We want to display in a variety of human readable formats which i'm clear the format option allows us to do. However, the datepicker instance doesn't both persistently store the converted ISO value as the actual input value and make both the display and submit value formats available to the DOM for calculations and printing. |
Thanks @MatTheCat , altFormat is exactly what is needed! |
Just to be clear, |
Hm, with altField it's still nice, but not as attractive, since you'll need to create additional field to manage this. But it's better than form submit hook probably. |
I think it's better too, and the main point is that it can be managed by the datepicker. EDIT: maybe |
Adding to use cases; However, if; "displayFormat" and "valueFormat" parameters were different, i would simply set valueFormat to iso8601 standart and displayFormat to my localized moment strings. I hope i am clear. |
@1dot44mb, the problem is that there is no easy way to implement this, without hooking into form submit. Otherwise the use case seems to be very frequent. |
@1dot44mb I don't want to touch your form anymore then I have. If you want to post a different format then the input, grab the It shouldn't be up to this library to do that for you. |
|
Once again, but why? Why do I need to duplicate functions that already exist? If you want a different format to a different field, listen to the change event and set the input value to whatever you want. |
Hi,
Would be great to have an option to store date in one format (my db format YYYY-MM-DD, mysql) but display the picker to the user in the local format 'M/D/YY' (US). And when he changes the date I want input.val() become YYYY-MM-DD again (so I can save it to the db).
Thanks for the great lib!
The text was updated successfully, but these errors were encountered: