In my web site, I have two date inputs,
<label>From : </label><input class="datepicker" id="from" name="from" value="<?php echo $from;?>" size=11 type="text">
<label>To : </label><input class="datepicker" id="to" name="to" value="<?php echo $to ;?>" size=11 type="text">
And in the javascript part, I have the following code
$(function() {
$( ".datepicker" ).datepicker({ altFormat: 'yy-mm-dd' });
//getter
var altFormat = $( ".datepicker" ).datepicker( "option", "altFormat" );
//setter
$( ".datepicker" ).datepicker( "option", "altFormat", 'yy-mm-dd' );
});
But when I select the date, it still returns a date with 04/04/2012 format instead of yy-mm-dd.
How should I solve this problem ?
Thanks
Lol, here we go again. first of all:
altFormat:
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 functiondateFormat:
The format for parsed and displayed dates. This attribute is one of the regionalisation attributes. For a full list of the possible formats see theformatDatefunction.See Working jsFiddle Here
You might also want to see an answer i gave a few minutes ago here, with more fiddles.