您的位置:首页 > 其它

完美解决日期天数加减问题

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);})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: