- In the development process some of the foreground page time control we need to give the default current time, jquery can easily help us implement, the code is as follows
1//Yesterday's time 2 var day1 = new Date (); 3 Day1.settime (Day1.gettime () -24*60*60*1000); 4 var S1 = day1.getfullyear () + "-" + (Day1.getmonth () +1) + "-" + day1.getdate (); 5//Today's time 6 var day2 = new Date (); 7 Day2.settime (Day2.gettime ()); 8 var s2 = day2.getfullyear () + "-" + (Day2.getmonth () +1) + "-" + day2.getdate (); 9//Tomorrow's time: var day3 = new Date (), Day3.settime (Day3.gettime () +24*60*60*1000), var s3 = Day3.getfullyear () + "-" + (day3 . GetMonth () +1) + "-" + day3.getdate (); 13//Splicing time function Show () {$ var str = "" + S1 + "to" + s2;16 return str;17 }18//Assign Value DOUBLEDATE19 $ (' #dateS '). Val (show ());
- Here's how to get to the time and seconds
1 function Writecurrentdate () {2 var now = new Date (), 3 var year = Now.getfullyear (); var month = Now.getmonth ();//Get month 5 var date = Now.getdate ();//Get date 6 var day = Now.getday ();//Get Week 7 var hour = now.gethours ();//Get hour 8 var minu = Now.getminutes ();//Get minutes 9 var sec = Now.getseconds (); To the second of var MS = Now.getmilliseconds ();//Gets the millisecond one-by-one var week;12 month = month + 1;13 if (month < ; month = "0" + month;14 if (date <) date = "0" + date;15 if (hour < ten) hour = "0" + hour;16 if (Minu <) Minu = "0" + minu;17 if (sec <) sec = "0" + sec;18 if (MS < +) ms = "0" + ms;19 var arr_week = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"), week = Arr_week[day] * var time = "", "time = year +" years "+ month +" Month "+ Date +" Day "+" "+ Hour +": "+ Minu +": "+ sec + "" + week;23The current date is assigned to the current date input box (JQuery Easyui) $ ("#currentDate"). HTML (time); 25//Set the execution interval of the function that gets the current date, refreshed every 1000 milliseconds. $ var timer = setTimeout ("Writecurrentdate ()", 1000); 27}
D
[Dbw]js Get current time (yesterday, today, tomorrow)