<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); })
完美解决日期天数加减问题
最新推荐文章于 2024-10-11 20:00:00 发布