<script type="Text/javascript">function Getlastdate () {varDate =NewDate (); varmonth = Date.getmonth () +1; varDay =date.getdate (); varHH =date.gethours (); varMM =date.getminutes (); varSS =date.getseconds (); varYear =date.getfullyear (); alert (year); varym; varyear1; Day= Day-Ten; if(Day <=0) { Day=Mygetday (day, month, year); varmonths =Mygetmonth (month); Ym= Months.split (","); Year1= ym[0]; Day=formatdate (day); Month= FormatDate (ym[1]); returnYear1 +"-"+ Month +"-"+ Day +" "+ hh +":"+ mm +":"+SS; } Else { returnYear +"-"+ Month +"-"+ Day +" "+ hh +":"+ mm +":"+SS; } } //get the date of a dayfunction Mygetday (day, month, year) {varDaynum = -; if(Month = =2|| month = =4|| month = =6|| month = =8|| month = =9|| month = =1|| month = = One) {Daynum= to; } Else if(Month = =3) { if(Year%4==0) {Daynum= in; } Else{daynum= -; }} Day= Daynum +Day ; returnDay ; } //get the month of a dayfunction Mygetmonth (month) {varYear =NewDate (). getFullYear (); if(Month = =1) {Month= A; year= year-1; } Else{Month= Month-1; } returnYear +","+month; } function FormatDate (d) {if(D.tostring (). length = =1) {D="0"+D; } returnD; } $ (function () {$ ('#birthday'). Datetimebox ('SetValue', Getlastdate ()); }); </script> <script type="Text/javascript">function Getlastdate () {varDate =NewDate ();//Get current Time varmonth = Date.getmonth () +1; varDay =date.getdate (); varHH =date.gethours (); varMM =date.getminutes (); varSS =date.getseconds (); varYear =date.getfullyear (); alert (year); varym; varyear1; Day= Day-Ten;//get 10 days ago if(Day <=0) { Day=Mygetday (day, month, year); varmonths =Mygetmonth (month); Ym= Months.split (","); Year1= ym[0]; Day=formatdate (day); Month= FormatDate (ym[1]); returnYear1 +"-"+ Month +"-"+ Day +" "+ hh +":"+ mm +":"+SS; } Else { returnYear +"-"+ Month +"-"+ Day +" "+ hh +":"+ mm +":"+SS; } } //get the date of a dayfunction Mygetday (day, month, year) {varDaynum = -; if(Month = =2|| month = =4|| month = =6|| month = =8|| month = =9|| month = =1|| month = = One) {Daynum= to; } Else if(Month = =3) { if(Year%4==0) {Daynum= in; } Else{daynum= -; }} Day= Daynum +Day ; returnDay ; } //get the month of a dayfunction Mygetmonth (month) {varYear =NewDate (). getFullYear (); if(Month = =1) {Month= A; year= year-1; } Else{Month= Month-1; } returnYear +","+month; } function FormatDate (d) {if(D.tostring (). length = =1) {D="0"+D; } returnD; }//Test Fill text box$ (function () {$ ('#birthday'). Datetimebox ('SetValue', Getlastdate ()); }); </script>
JS gets the time according to the current time n days ago