简体   繁体   English

我想将日期选择器格式更改为yyyy-mm-dd

[英]I want to change date-picker format as yyyy-mm-dd

$(function () {

$('.date-picker').datepicker();

)};

I was using above code but i changed the code to change the format as: 我正在使用上面的代码,但是我更改了代码以将格式更改为:

$(function () {

$('.date-picker').datepicker({ dateFormat: 'yy-mm-dd' });

});

Though i have changed it's not working... anybody there to help? 尽管我已经更改了它,但是它不起作用...有人在帮忙吗?

Just copy paste this code in a blank html file and open in browser. 只需复制将此代码粘贴到空白html文件中,然后在浏览器中打开即可。

It has all the settings that you require, so hoping will help you 它具有您所需的所有设置,因此希望对您有所帮助

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Datepicker - Format date</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
  $(function() {
    $( "#datepicker" ).datepicker();
    $( "#format" ).change(function() {
      $( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val() );
    });
  });
  </script>
</head>
<body>

<p>Date: <input type="text" id="datepicker" size="30"></p>

<p>Format options:<br>
  <select id="format">
    <option value="mm/dd/yy">Default - mm/dd/yy</option>
    <option value="yy-mm-dd">ISO 8601 - yy-mm-dd</option>
    <option value="d M, y">Short - d M, y</option>
    <option value="d MM, y">Medium - d MM, y</option>
    <option value="DD, d MM, yy">Full - DD, d MM, yy</option>
    <option value="&apos;day&apos; d &apos;of&apos; MM &apos;in the year&apos; yy">With text - 'day' d 'of' MM 'in the year' yy</option>
  </select>
</p>


</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM