Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery datepicker display format

I have MySQL table with date field (yy-mm-dd).

And I have form with datepicker that edits it and it works fine.

BUT at the frontend date is displayed as mm-dd-yy and that can be confusing.

I'd like field with datepicker to display value as mm-dd-yy, but the actual value should be of the old format (yy-mm-dd).

How to reach this?

Added: I know how to change format of date. I want separate displayed value and actual value. That's what it is all about.

like image 845
Dmitry Avatar asked Dec 29 '11 19:12

Dmitry


1 Answers

The jQuery UI Datepicker widget comes with altField and altFormat options that allow you to set a secondary (hidden if you want) form input to store the date in whatever format you want:

$( ".selector" ).datepicker({
    altField  : '#actualDate',
    altFormat : 'yy-mm-dd'
});

Source: http://jqueryui.com/demos/datepicker/#option-altFormat

Here is a demo: http://jsfiddle.net/MmKmq/

like image 198
Jasper Avatar answered Nov 15 '22 11:11

Jasper