JS Date Time Selector

Source: Internet
Author: User


Original address: http://www.yanwushu.com/post/44.html

This article describes the use of a date and time selector. This selector is implemented by jQueryUI and supports a time selection that is accurate to milliseconds.

This selector project address is http://trentrichardson.com/examples/timepicker/

Demo Address: http://www.helloweba.com/demo/timepicker/

Download Address: http://download.csdn.net/detail/yanwushu/7721933


Effect chart

In addition to the JS time selector can also refer to other projects

http://www.bootcss.com/p/bootstrap-datetimepicker/

http://guangqiang.iteye.com/blog/1559262


General steps to use

This control is very simple to use, just introduce JS and CSS, and then add a jquery code.


introduction of JS library

<scripttype= "Text/javascript" src= ". /commons/datetimepicker/js/jquery-1.7.2.min.js "></script>

<scripttype= "Text/javascript" src= ". /commons/datetimepicker/js/jquery-ui.js "></script>

<scripttype= "Text/javascript" src= ". /commons/datetimepicker/js/jquery-ui-slide.min.js "></script>

<script type= "Text/javascript" src= ". /commons/datetimepicker/js/jquery-ui-timepicker-addon.js "></script>


Introducing Styles

<link rel= "stylesheet" type= " text/css" href= "Css/jquery-ui.css"/>

<script type= "Text/javascript" src= "Js/jquery.min.js" ></script>

<script type= "Text/javascript" src= "Js/jquery-ui.js" ></script>

<script type= "Text/javascript" src= "Js/jquery-ui-timepicker-addon.js" ></script>

In addition to introducing the jquery UI style, the following styles are added to control the appearance of the time control.

. Ui-timepicker-div. ui-widget-header {margin-bottom:8px;}

. ui-timepicker-div dl {text-align:left;}

. ui-timepicker-div DL dt {height:25px; Margin-bottom: -25px;}

. Ui-timepicker-div DL dd {margin:0 10px 10px 65px;}

. ui-timepicker-div td {font-size:90%;}

. Ui-tpicker-grid-label {background:none; border:none; margin:0; padding:0;}

. Ui_tpicker_hour_label,.ui_tpicker_minute_label,.ui_tpicker_second_label,

. ui_tpicker_millisec_label,.ui_tpicker_time_label{padding-left:20px}


Initializing Controls

<input type= "text" id= "Example"/>

$ (' #example_1 '). DateTimePicker ();

If you only need to display the time:

$ (' #example_2 '). Timepicker ();

Define Time Format:

$ (' #example_3 '). DateTimePicker ({

Showsecond:true,

Showmillisec:true,

timeformat: ' Hh:mm:ss:l '

});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.