DateTimePicker 时间控件:
http://xdsoft.net/jqplugins/datetimepicker/
可以参考文档设置各种属性,格式。
用法:
首先下载datetimepicker-master。
1.页面引入css,js文件(注意要放到body之后):
<!-- this should go after your </body> --><link rel="stylesheet" type="text/css" href="/microshop-settlement-server/resources/datetimepicker-master/jquery.datetimepicker.css" /><script src="/microshop-settlement-server/resources/datetimepicker-master/jquery.js"></script><script src="/microshop-settlement-server/resources/datetimepicker-master/build/jquery.datetimepicker.full.min.js"></script>
2.点击文本框弹出日历选项:
Html:
<input id="datetimepicker" type="text" name="createTime" value="<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${createTime }"/>" maxlength="20"/>
这里用到了jsp el标签fmt:所以页面要先引入:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
JavaScript:
<script type="text/javascript"> jQuery('#datetimepicker').datetimepicker({ format:'Y-m-d H:i:s' //这是设置日历格式 });</script>
http://php.net/manual/ru/function.date.php(时间格式可以参考这个,如2009-01-01 10:00:01)
3.目录结构:
4.demo预览: