2

在我的网站中,我有两个日期输入,

 <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">

在javascript部分,我有以下代码

$(function() {
  $( ".datepicker" ).datepicker({ altFormat: 'yy-mm-dd' });
  //getter
  var altFormat = $( ".datepicker" ).datepicker( "option", "altFormat" );
  //setter
  $( ".datepicker" ).datepicker( "option", "altFormat", 'yy-mm-dd' );
  });

但是当我选择日期时,它仍然返回格式为 04/04/2012 的日期,而不是 yy-mm-dd。

我应该如何解决这个问题?

谢谢

4

1 回答 1

0

大声笑,我们又来了。首先:

  • 替代格式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

  • 日期格式The format for parsed and displayed dates. This attribute is one of the regionalisation attributes. For a full list of the possible formats see the格式日期function.

在此处查看工作jsFiddle

你可能还想看看我几分钟前在这里给出的答案,还有更多的小提琴

于 2012-04-09T20:22:45.013 回答