1.只顯示年月日
$( ".datepicker").datepicker({ needDay:true, changeMonth: true, //顯示月份 changeYear: true, //顯示年份 showButtonPanel: true, //顯示按鈕 dateFormat: 'yy-mm-dd', //日期格式 });
2.只顯示時分秒(需要引入時間插件文件。1.【jQuery-Timepicker-Addon/jquery-ui-timepicker-addon.js】2.漢化【datetimepicker/js/jquery.ui.datepicker-zh-CN.js.js】)
$('.datepicker-times').timepicker({
showButtonPanel: true, //顯示按鈕 timeFormat: "HH:mm:ss", });
3.顯示年月日時分秒,
$('.datepicker-times').datetimepicker({ needDay:true, changeMonth: true, //顯示月份 changeYear: true, //顯示年份 showButtonPanel: true, //顯示按鈕 timeFormat: "HH:mm:ss", dateFormat: "yy-mm-dd" });
官網:http://trentrichardson.com/examples/timepicker/#tp-examples