I've got an input using the datepicker tool from jQuery. Now I know I can set the date format being used by the datepicker. Problem is: I'd like to show the date in the german format to the user, while using the english format for the database (dd-mm-yy to yy-mm-dd).
What I have here now is the following:
$(".date").datepicker({
dateFormat: "dd-mm-yy",
onSelect: function(dateText, inst) {
$("#test").html($.inst.formatDate('yy-mm-dd', dateText); // What exactly do I have to do, to get the date from dd-mm-yy to yy-mm-dd
}
});
Probably your best option is to use altField
and altFormat
properties for the datepicker, which are there exactly for this reason: API Docs.
If you set the altField to an hidden input field, you can then get the data from there when uploading to the DB or for anything else you need the alternate date format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With