Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery datepicker Difference between "dateFormat" & "altFormat"

According to this documentation, http://jqueryui.com/demos/datepicker/#option-altFormat

I can set a different date format for the user to see, and a different format to actually send to the server.

However, both seem to show the same format.

Here is my code:

        $("#joindate").datepicker({
            dateFormat: $.datepicker.TIMESTAMP,
            altFormat: 'yy-mm-dd'
        });

And, I would want the user to see yy-mm-dd format, and send the timestamp to the server using my post request. I have switched the values of altFormat and dateFormat, but either I get yy-mm-dd in both (textbox and $_POST) or the timestamp in both.

Is there a workaround to this ?

like image 625
Hrishikesh Choudhari Avatar asked Apr 11 '11 09:04

Hrishikesh Choudhari


People also ask

What is jQuery Datepicker?

A date-picker of jQuery UI is used to provide a calendar to the user to select the date from a Calendar. This date picker usually connected to a text-box so user selection of date from the calendar can be transferred to the textbox.

How do I change the Datepicker format?

An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field.

How do I change Datepicker format from DD MM to YYYY?

The jQuery DatePicker plugin supports multiple Date formats and in order to set the dd/MM/yyyy Date format, the dateFormat property needs to be set. The following HTML Markup consists of a TextBox which has been made Read Only.

What format does Datepicker return?

By default, the date format of the jQuery UI Datepicker is the US format mm/dd/yy, but we can set it to a custom display format, eg: for European dates dd-mm-yyyy and so on. The solution is to use the date picker dateFormat option.


1 Answers

I think you must read this

The dateFormat to be used for the altField option. This allows one date format to be shown to the user for selection purposes, while a different format is actually sent behind the scenes. For a full list of the possible formats see the formatDate function

Reference:

http://api.jqueryui.com/datepicker/#option-altField

like image 108
diEcho Avatar answered Oct 18 '22 18:10

diEcho