the requirement is to display a warm reminder within the penultimate 5 days of each month. The code is as follows: calculate the last day of the month, the current time, and the penultimate 5th day, and compare them with the timestamp of three times. but there is always a problem: can you help me to see what"s wrong with my time calculation?
<!-- -->
<div class="inquire_search message_warm" id="message_warm">
<ul>
<li>
<img class="inquire_img" onclick="selectDeviceList()" src="${pageContext.request.contextPath}/resources/new/${sessionScope.skin }/image/message_hot.png"/>
<span class="inquire_remind"><spring:message code="warmTip.PaySIMcard"/></span>
</li>
<li>
<img class="inquire_img" onclick="selectDeviceList()" src="${pageContext.request.contextPath}/resources/new/${sessionScope.skin }/image/message_hot.png"/>
<span class="inquire_remind"><spring:message code="warmTip.PaySIMcard"/></span>
</li>
</ul>
</div>
/* */
$(function(){
//
var mydate = new Date();
var timestamp = Date.parse(new Date());
//
var currentMonth=mydate.getMonth();
var nextMonth=PPcurrentMonth;
var nextMonthFirstDay=new Date(mydate.getFullYear(),nextMonth,1);
var oneDay=1000*60*60*24;
var lastMonthDay = nextMonthFirstDay-oneDay;
// 5
var fiveLastDay = (nextMonthFirstDay-oneDay)-oneDay*5;
// 5
if(fiveLastDay<timestamp){
if(timestamp<lastMonthDay){
$("-sharpmessage_warm").show();
setInterval("AutoScroll("-sharpmessage_warm")", 3000);
}
}else{
$("-sharpmessage_warm").hide();
}
});
/* */
function timestampToTime(time) {
// yyyy-MM-dd hh:mm:ss
var date = new Date(time);
Y = date.getFullYear() + "-";
M = (date.getMonth()+1 < 10 ? "0"+(date.getMonth()+1) : date.getMonth()+1) + "-";
D = date.getDate() + " ";
h = date.getHours() + ":";
m = date.getMinutes() + ":";
s = date.getSeconds();
return Y+M+D+h+m+s;
}