Use JS in a text box to set the current time, two button, a point add one day, one point to reduce the day.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">
$ = function (o) {return typeof o = = ' string '? document.getElementById (o): o};
Set current date var ma = [[' 1 ', ' 3 ', ' 5 ', ' 7 ', ' 8 ', ' 10 '],[' 4 ', ' 6 ', ' 9 ', ' 11 ']];
var dd = new Date ();
var x = dd.tolocalestring ();
var o = pasdate (x);
$ (' date '). Value = O.join ('-');
Conversion Date function pasdate (DA) {var yp = Da.indexof (' year '), MP = Da.indexof (' month '),
DP = Da.indexof (' Day '); var y = da.substr (0,yp), M = da.substr (YP + 1,mp-yp-1), D = DA.SUBSTR (MP + 1,dp-mp-1
);
return [y,m,d]; //Determine if array a exists in element n function check (n,a) {for var i = 0,len = A.length;i < Len;
i++) {if (a[i] = N) {return true;
return false;
//Leap year? FUnction isleap (y) {return (y% 4 = 0 && y!= 0) | | y% = = 0)? true:false;
//implementation plus minus F: ' 1 ' Plus, ' 0 ' minus function trans (o,f) {var d = o.split ('-');
var L = isleap (d[0]); if (f = = ' 1 ') {if ((check (d[1],ma[0)) && (d[2] = ' 31 ') | |
(check (d[1],ma[1]) && (d[2] = = ' 30 ') | | (d[1] = = ' 2 ' && d[2] = = ' &&!l ') | | (d[1] = = ' 2 ' && d[2] = = ' O ' && l))
{return d[0] + '-' + (d[1] * 1 + 1) + '-' + 1;
else if (d[1] = = ' && d[2] = = ' {return (d[0] * 1 + 1) + '-' + ' 1-1 ';
else {return d[0] + '-' + d[1] + '-' + (d[2] * 1 + 1);
' Else if ' (f = = ' 0 ') {if (check (d[1]-1,ma[0]) && (d[2] = = ' 1 ')) { return d[0] + '-' + (D[1]-1) + '-' + ' 31 '; ' Else if (check (d[1]-1,ma[1]) && (d[2] = = ' 1 ')) {return d[0] + '-' + (D[1]-1) + '-' +
' 30 ';
else if (d[1] = = ' 1 ' && d[2] = = ' 1 ') {return (d[0]-1) + '-' + ' 12-31 ';
else if (d[1] = = ' 3 ' && d[2] = = ' 1 ' &&!l) {return d[0] + '-' + ' 2-28 '; else if (d[1] = = ' 3 ' && d[2] = = ' 1 ' && l) {return d[0] + '-'
+ ' 2-29 ';
else {return d[0] + '-' + d[1] + '-' + (D[2]-1);
} else {return;
} $ (' Add '). onclick = function () {var v = $ (' date '). Value;
$ (' date '). Value = trans (V, ' 1 '); } $ (' minus '). onclick = FunCtion () {var v = $ (' date '). Value;
$ (' date '). Value = trans (V, ' 0 '); }
Reprint Address: http://www.cnblogs.com/suizhikuo/archive/2011/12/10/2283430.html