完美解决日期天数加减问题
2017-06-05 17:27
423 查看
<span class="form_style"> <label class="control-label">比对时间:</label> <div class="date datetimepicker" style="display:inline-block;padding:0;" id="startTime" data-date-format="yyyy-MM"> <input class="form-control span2" name="startDate" value="<#if requestReportLogSearchCondition??>${requestReportLogSearchCondition.startDate!''}</#if>" id="startDate" type="text" required="true"> <span class="add-on"><i class="icon-remove"></i></span> <span class="add-on"><i class="icon-th"></i></span> </div> <label><font color="red">*</font></label> </span> <span class="form_style" style="display: none"> <label class="control-label">至:</label> <div class="date datetimepicker" style="display:inline-block;padding:0;" id="endTime" data-date-format="yyyy-MM-dd"> <input class="form-control span2" value="<#if requestLogSearchCondition??>${requestLogSearchCondition.endDate!''}</#if>" name="endDate" id="endDate" type="text" required="true" disabled> <span class="add-on"><i class="icon-remove"></i></span> <span class="add-on"><i class="icon-th"></i></span> </div> <label><font color="red">*</font></label> </span> <span class="form_style"> <label class="control-label">至:</label> <div class="date datetimepicker" style="display:inline-block;padding:0;" id="endTimeVal1" data-date-format="yyyy-MM-dd"> <input class="form-control span2" value="<#if requestLogSearchCondition??>${requestLogSearchCondition.endDate!''}</#if>" name="endTimeVal" id="endTimeVal" type="text" disabled> <span class="add-on"><i class="icon-remove"></i></span> <span class="add-on"><i class="icon-th"></i></span> </div> <label><font color="red">*</font></label> </span>
$("#startDate").change(function () {debugger;var startDate = $("#startDate").val();var curDate = new Date(startDate);var curMonth = curDate.getMonth();curDate.setMonth(curMonth + 1);curDate.setDate(0);var day = curDate.getDate();//当月天数var startTime = new Date(startDate);startTime = startTime.valueOf();startTime = startTime + day * 24 * 60 * 60 * 1000 - 1 * 24 * 60 * 60 * 1000;startTime = new Date(startTime);var now = "";/*+ "-" + startTime.getDate()*/now = startTime.getFullYear() + "-" + (startTime.getMonth() + 1);$("#endTimeVal").val(now);})$("#startDate").change(function () {debugger;var startDate = $("#startDate").val();var curDate = new Date(startDate);var curMonth = curDate.getMonth();curDate.setMonth(curMonth + 1);curDate.setDate(0);var day = curDate.getDate();//当月天数var startTime = new Date(startDate);startTime = startTime.valueOf();startTime = startTime + day * 24 * 60 * 60 * 1000;startTime = new Date(startTime);var now = "";/*+ "-" + startTime.getDate()*/now = startTime.getFullYear() + "-" + (startTime.getMonth() + 1);$("#endDate").val(now);})
相关文章推荐
- 完美解决表单被外部提交问题
- 智能安全实验室-杀马(Defendio) 2.5.0.426 :解决因日期超过28日(29/30/31)出现的“无效属性”导致杀马无法启动的问题;
- 完美解决SQL Server 安装问题:以前的某个程序安装已在安装计算机上创建挂起的文件操作
- 计算任意两个日期之间的天数问题
- ajax完美解决的一个麻烦问题
- 关于TreeView对添加海量节点的响应(续)-问题的完美解决
- 完美解决IIS服务器无法加载应用程序 '/LM/W3SVC/1/ROOT'-没有注册类别的问题
- 完美解决dedecms中的[html][/html]和[code][/code]问题
- ajax完美解决的一个麻烦问题
- WebSAbbs v1.0 开发进度 - 完美解决请求队列问题
- 完美解决无法无法显示隐藏文件的问题(svohost.exe xsx.exe)
- 完美解决JS中汉字显示乱码问题(已解决)
- 完美解决 VS2003/2005 代码编辑器字体问题的方案。
- 原创::完美解决中文问题的FVWM配置 :-)
- 完美解决PJ的Cookies保存时限问题!可选择记录登陆时长!
- 一步一步SharePoint 2007之二十二:完美解决实现Form认证后无法再用SharePoint Designer编辑网站的问题
- 完美解决事件查看器中查看应用程序日志导致MMC.EXE出错问题
- Firefox插件完美解决BT种子下载问题
- 日期条件查询 问题解决
- 完美解决双核运行游戏不稳定问题,并提升XP运行效率正文分析错误