2017-02-20 150 views
0

我尋覓了很多互聯網和審判他們,但他們都一起不工作我的問題是如何與日期選擇器同時顯示時間選擇器如何添加時間選擇與日期選擇器

我已經有了這個代碼對於日期選擇器

<html> 
 
<head> 
 

 
<title>datetimepicker</title> 
 
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.0.min.js" type="text/javascript"></script> 
 
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/jquery-ui.min.js" type="text/javascript"></script> 
 
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/themes/blitzer/jqueryui.css"rel="Stylesheet" type="text/css" /> 
 
<script type="text/javascript" src="http://cdn.jsdelivr.net/json2/0.1/json2.js"></script> 
 
    </head> 
 
    <body> 
 
    <input class="w3-input w3-border " type="text" id="txt_fupdate" size="25" title="Follow Up Date" placeholder="Follow Up Date " runat="server" required>  
 
      <script type="text/javascript"> 
 
       $(function() { 
 
        $("#txt_fupdate").datepicker({ dateFormat: "dd-mm-yy" }).val() 
 
       }); 
 

 
      </script> 
 
    </body> 
 
    </html>

我的問題是我怎樣才能添加或更新代碼,以獲得時間選擇,請幫助對此。

+1

'jquery ui'默認沒有時間選擇器,但這裏是一個插件'http:// trentrichardson.com/examples/timepicker /' – Mairaj

+0

或https://plugins.jquery.com/datetimepicker/ – vijayP

+0

檢查這: - http://jquer.in/jquery-plugins-for-html5-forms/datetimepicker/ –

回答

0

至於說,你需要一個插件, 試試這個:https://plugins.jquery.com/simple-dtpicker/

請記住,包括您的文件夾中所需的文件

jquery.simple-dtpicker.js和jquery.simple,dtpicker.css

您的代碼假設看起來像這樣:

<html> 

<head> 
     <title>datetimepicker</title> 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script> 
     <script src="https://cdn.rawgit.com/mugifly/jquery-simple-datetimepicker/72933bbe/jquery.simple-dtpicker.js"></script> 
     <link href="https://cdn.rawgit.com/mugifly/jquery-simple-datetimepicker/72933bbe/jquery.simple-dtpicker.css" rel="stylesheet" /> 
    </head> 

    <body> 

     <input id="txt_fupdate" class="w3-input w3-border " placeholder="Follow Up Date " required="" size="25" title="Follow Up Date" type="text" /> 
     <script type="text/javascript"> 
      $(function() { 
       $('#txt_fupdate').appendDtpicker({ 
        "closeOnSelected": true 

       }); 


      }); 
     </script> 

    </body> 

    </html> 

它的簡單,有幾個好等特點蘇本地化。

+0

它的工作正常,但如何輸入日期格式爲* dd-mm-yyyy hh:mm * – Suhas

+1

我得到了那個''dateFormat':「DD-MM-YYYY H:mmTT」 '通過使用這個我們可以改變 – Suhas

相關問題