1. The time control of some foreground pages in the development process we need to give the default current time, jquery can be easily implemented for us, the code is as follows:
//yesterday's TimevarDay1 =NewDate ();d ay1.settime (Day1.gettime ()-24*60*60*1000);varS1 = day1.getfullyear () + "-" + (Day1.getmonth () +1) + "-" +day1.getdate ();//Today's TimevarDay2 =NewDate ();d ay2.settime (Day2.gettime ());varS2 = day2.getfullyear () + "-" + (Day2.getmonth () +1) + "-" +day2.getdate ();//Tomorrow's TimevarDay3 =NewDate ();d ay3.settime (Day3.gettime ()+24*60*60*1000);varS3 = Day3.getfullyear () + "-" + (Day3.getmonth () +1) + "-" +day3.getdate ();//splicing TimefunctionShow () {varstr = "" + S1 + "to" +S2; returnstr;}//Assignment Doubledate$ (' #dateS '). Val (show ());
2. Here's how to get to the time and seconds
functionwritecurrentdate () {varnow =NewDate (); varYear = Now.getfullyear ();//Get year varmonth = Now.getmonth ();//Get the Month varDate = Now.getdate ();//Get Date varDay = Now.getday ();//get a few weeks varhour = Now.gethours ();//Get the Hour varMinu = Now.getminutes ();//Get minutes varSEC = Now.getseconds ();//Get seconds varMS = Now.getmilliseconds ();//get milliseconds varWeek; Month= month + 1; if(Month <) month = "0" +month; if(Date <) date = "0" +date; if(Hour <) hour = "0" +hour; if(Minu <) Minu = "0" +Minu; if(sec <) sec = "0" +sec; ifMs < MS = "0" +MS; varArr_week =NewArray ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); Week=Arr_week[day]; varTime = ""; time= year + "years" + month + "Month" + Date + "Day" + "+ Hour +": "+ Minu +": "+ sec +" +Week; //The current date is assigned to the current date input box (jQuery Easyui)$ ("#currentDate"). HTML (time); //sets the execution interval of the function that gets the current date, refreshed every 1000 milliseconds. varTimer = SetTimeout ("Writecurrentdate ()", 1000); }
JS get current time (yesterday, today, tomorrow)