Html
    Css
    Js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
document.write("36" + getNowFormatDate(36));
function getNowFormatDate(s) {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
var shi = date.getHours();
var fen = date.getMinutes();
var miao = date.getSeconds();
var nian = date.getFullYear();
var sjif = strDate - s;
if (sjif > 0) {
strDate = sjif
} else {
var i = 1;
sjif = sjif - sjif * 2 // 80
//
var sgy = month - i;
if (sgy <= 0) {
sgy = sgy - sgy * 2;
sgy = 12 - sgy;
}
if (s >= 365) {
nian = nian - 1;
}
var day = new Date(date.getFullYear(), sgy, 0);
//
var daycount = day.getDate();
var yfif = daycount - sjif; // 31 - 80 = -49
if (yfif > 0) {
strDate = yfif;
month = sgy;
} else {
dkbl()
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
↑上面代码改变,会自动显示代码结果 jQuery调用版本:1.10.2
 立即下载

获取前几天时间值

alert(getNowFormatDate(36));

直接调用36 为当前时间的36天前

1
      _毒?_〃ゅ℃0
      2017/4/13 12:40:17

      不错,可以一用

      回复