jQuery Datepicker日期格式不起作用

时间:2015-12-03 08:39:55

标签: jquery html datepicker

我似乎无法获得日期格式' yyyy / mm / dd'在Datepicker工作 - 我已经尝试了所有的"解决方案"在那里,到目前为止对我有用的唯一事情是this。但正如您所看到的,它是一个下拉菜单,我不想每次都选择格式 - 我只是希望 那样。

现在,链接脚本就像这样:

<?  include('./config.php') ?>
<?
    @Set_Time_Limit(0);

    $INI_ADMIN_PASSWORD = $_GET[INI_ADMIN_PASSWORD];
    $INI_ftp_server = $_GET[INI_ftp_server];  
    $INI_info_path = $_GET[INI_info_path];                                  
    $INI_server_info_path = $_GET[INI_server_info_path];
    $INI_server_tmp_path = $_GET[INI_server_tmp_path];
    $INI_ftp_user = $_GET[INI_ftp_user];
    $INI_ftp_pass = $_GET[INI_ftp_pass];                               
    $spojeni_ftp = $_GET[spojeni_ftp];
    $soubor = $_FILES["soubor"]["name"];

    $titulek_form = $_POST["titulek_form"];
    $datum_form = $_POST["datum_form"]; 
    $DatumInt = $_POST["DatumInt"];
    $MaxID = $_POST["MaxID"];     
    $prenos_info = $_POST["prenos_info"];
    $vloz_info = $_POST["vloz_info"];   
    $jmeno = $_POST["jmeno"];
    $vyber2 = $_POST["vyber2"];
    $datum2 = $_POST["datum2"];
    $nazev = $_POST["nazev"]; 
    $soubor_name = $_POST["soubor_name"];
    $cislo = $_POST["cislo"];
    $jmeno =  $_POST["jmeno"];*

IF($PASSWORD==$INI_ADMIN_PASSWORD):

    $spojeni = @MySQL_Connect($se, $uz, $he);
    $db = @MySQL_Select_DB($DB);

    $vyber2 = @MySQL_Query("SELECT Max(ID) FROM info");
    $MaxID = @MySQL_Result($vyber2, 0) +1;

    $titulek_form = HTMLSpecialChars($titulek_form);
    $datum_form = HTMLSpecialChars($datum_form);

    $datum2 = Explode(".", $datum_form);

    $DatumInt = MkTime(0,0,0, $datum2[1], $datum2[0], $datum2[2]);

    $jmeno = "info";

    $i = 1;

    do
{
         if($i==1) $jmeno_old = $jmeno;
         $jmeno = $jmeno_old;
         $nazev = Explode(".", $soubor_name);
         SRand((double)MicroTime()*1e6);
         $cislo = Rand (1, 9999);
//       $nazev[0] .= $cislo;
         $jmeno .= $cislo.".".$nazev[1];
         $i++;
}
    While(@File_Exists("$INI_info_path$jmeno"));


    $vloz_info = @MySQL_Query("INSERT INTO info VALUES ('$MaxID', '$titulek_form', '$datum_form', '$jmeno', '$DatumInt')");


// ***  FTP start


        @chdir("$INI_server_tmp_path");                                                     // docasny adresar
        $spojeni_ftp = @ftp_connect("$INI_ftp_server");                         // pripojeni k FTP serveru
        @ftp_login($spojeni_ftp, "$INI_ftp_user", "$INI_ftp_pass");                             // prihlaseni k FTP serveru

        $prenos_info = @ftp_put($spojeni_ftp, "$INI_info_ftp_path$jmeno", "$soubor", FTP_BINARY);       // kam se ma soubor ulozit

        @chdir("$INI_server_home_path");                                                // nastaveni domovskeho adresare
        @ftp_close($spojeni_ftp);                                                               // odhlaseni od FTP serveru


// *** FTP end

    Header("Location: status.php?prenos_info=$prenos_info&vloz_info=$vloz_info");
?>
<?
ELSE:
    Echo "<p>Error</b></p>";
ENDIF;
?>

下拉:

<script>
    $(function() {
        $( "#datepicker" ).datepicker();
        $( "#format" ).change(function() {
            $( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val() );
        });
    });
</script>

对jQuery非常好,所以我绝对不知道如何转换&#34;。

2 个答案:

答案 0 :(得分:3)

$(function() {
    $("#datepicker").datepicker({ 
            dateFormat: 'yy/mm/dd'
    }); 
});

这样做,你应该在初始化datepicker时设置它。

答案 1 :(得分:0)

您的jQuery datepicker应如下所示构建。我已添加changeMonthchangeYear为您提供了附加功能,但如果您不需要,可以将其删除。要将datepicker附加到您的html,请使用input元素并设置它的ID,如下所示。

请记住,您需要在下面包含两个jQuery引用才能访问库。

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>



<script>
        $(function () {
            $("#datepicker").datepicker({ dateFormat: "yy/mm/dd", changeMonth: true, changeYear: true });
        });
    </script>


<input type="date" id="datepicker" />

工作示例Codepen