This example for you to share the current time JS to obtain the specific code for your reference, the specific content as follows
JS get current time (Yesterday, Today, tomorrow)
Time controls for some foreground pages in the development process we need to give the default current time, jquery can easily help us implement the code as follows
Yesterday's time
var day1 = new Date ();
Day1.settime (Day1.gettime () -24*60*60*1000);
var S1 = day1.getfullyear () + "-" + (Day1.getmonth () +1) + "-" + day1.getdate ();
Today's time
var day2 = new Date ();
Day2.settime (Day2.gettime ());
var s2 = day2.getfullyear () + "-" + (Day2.getmonth () +1) + "-" + day2.getdate ();
Tomorrow's time
var day3 = new Date ();
Day3.settime (Day3.gettime () +24*60*60*1000);
var s3 = Day3.getfullyear () + "-" + (Day3.getmonth () +1) + "-" + day3.getdate ();
Stitching time
function Show () {
var str = "" + S1 + "to" + S2;
return str;
}
Assignment doubledate
$ (' #dateS '). Val (show ());
The following is a specific time to get the method of seconds
function Writecurrentdate () {var now = new Date (); var year = Now.getfullyear (); Get year var month = Now.getmonth ();//Get month var date = Now.getdate ();//Get date var day = Now.getday ();//Get weeks Var hour = now.gethours ()//Get hour var minu = Now.getminutes ();//Get minutes var sec = now.getseconds ();//Get second var MS = no
W.getmilliseconds ()//Get millisecond Var week;
Month = month + 1;
if (Month <) month = "0" + month;
if (date < ten) date = "0" + date;
if (hour <) hour = "0" + hour;
if (Minu <) Minu = "0" + minu;
if (sec <) sec = "0" + sec;
if (MS < MB) ms = "0" + ms;
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;
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, and refreshes every 1000 milliseconds. var timer = settimeout ("Writecurrentdate ()", 1000); }
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.