简体   繁体   中英

how to add time picker along with date picker

i have searched a lot in internet and tried them but all of them are not working my problem is how to display time picker along with date picker

i already have this code for date picker

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

my question is how can i add or update that code to get time picker please help regarding this.

Have a look at this plugin: http://xdsoft.net/jqplugins/datetimepicker/

Alternatively, I would suggest that you can add an extra textbox on to the right of the datepicker and bind it with time picker like this one.

As said, you need a plugin, Try this one: https://plugins.jquery.com/simple-dtpicker/

Remember to include required files in your folder

jquery.simple-dtpicker.js and jquery.simple-dtpicker.css

And your code suppose to look like this:

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

Its simple and has several good features such localization.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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