发布网友 发布时间:2024-12-29 18:09
共2个回答
热心网友 时间:9分钟前
大概如此,具体的需求自己改吧
function init(){
var number = 300;
return number;
}
Date.prototype.Format = function (fmt) {//格式化日期的东西
if (!/(M+)/.test(fmt)) {
fmt = fmt.toLowerCase();
}
var time = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
//"q+": Math.floor((this.getMonth() + 3) / 3), //季度
//"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)){
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (var k in time) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(
RegExp.$1, (RegExp.$1.length == 1) ? (time[k]) : (("00" + time[k]).substr(("" + time[k]).length))
);
}
}
return fmt;
}
function getDate() {
var number;
var nowDay = parseInt(new Date().Format("dd"));
console.log(nowDay)
if (nowDay == 30) {//30天重置
number = init();
}
number = number - 5;
}
setInterval(getDate(), 24 * 60 * 60 * 1000);//一天执行一次
热心网友 时间:4分钟前
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
var temp1=1;
var temp2=300;
var arr=[];
for(var i=0;i<30;i++){
arr.push({
date:temp1+i,
value:temp2-5*i
})
}
console.log(arr);
</script>
</body>
</html>