Do Web pages often encounter the need to give time control to assign the current time requirements, every time you have to check the code on the Internet, more trouble, simply write down in the blog:
varMydate=NewDate (); varRealyear =mydate.getfullyear (); varMymonth = Mydate.getmonth () +1; varRealmonth=Mymonth; varMyday =mydate.getdate (); varRealday =Myday; if(mymonth<10) {Realmonth= "0" +Mymonth; } if(myday<10) {Realday= "0" +Myday; } varRealdate = realyear + '-' +realmonth+ '-' +Realday; $("Input[name= ' Entityvo.scrap_time ']"). Val (realdate);
Okay, I'm a lazy man.
The value obtained when getmonth is 0-11, so it needs to be +1 on the original basis.
To get the current date, you need to use GETDATE () instead of GetDay (), GetDay () Gets the current number of weeks.
All right, just put the time and seconds into it:
1 varMydate=NewDate ();2 varRealyear =mydate.getfullyear ();3 varMymonth = Mydate.getmonth () +1;4 varRealmonth=Mymonth;5 varMyday =mydate.getdate ();6 varRealday =Myday;7 varMyhour =mydate.gethours ();8 varRealhours =Myhour;9 varMyminute =mydate.getminutes ();Ten varRealminute =Myminute; One varMysecond =mydate.getseconds (); A varRealsecond =Mysecond; - if(mymonth<10){ -Realmonth= "0" +Mymonth; the } - if(myday<10){ -realday= "0" +Myday; - } + if(myminute<10){ -Realminute= "0" +Myminute; + } A if(myhour<10){ atrealhours= "0" +Myhour; - } - if(mysecond<10){ -Realsecond= "0" +Mysecond; - } - varRealdate = realyear + '-' +realmonth+ '-' +realday+ ' ' +realhours+ ': ' +realminute+ ': ' +Realsecond; in$ ("Input[name= ' Entityvo.scrap_time ')"). Val (realdate);
Well, after the need for the time can be directly to their own blog copy, lazy people are like this!
JS Generation Current Time