Formatted date time is 2017-07-09
functionformatdate (dates) {varmydate=NewDate (dates); Varmon=mydate.getmonth () +1; Mon= Mon.tostring (). Length <=1?"0"+Mon:mon; Vard=mydate.getdate (); D= D.tostring (). Length <=1?"0"+d:d; Varh=mydate.gethours (); H= H.tostring (). Length <=1?"0"+h:h; Varm=mydate.getminutes (); M= M.tostring (). length = =1?"0"+m:m; VARs=mydate.getseconds (); S= S.tostring (). length = =1?"0"+s:s; Returnmydate.getfullyear ()+"-"+mon+"-"+d+" "+h+":"+m+":"+s;}
Convert string to date format
New Date ("7","Up", 0,0,0); Console.log (mydate); // the new date () converts the number to the date type. However, the format "2017-07-18" cannot be converted to a date format.
Boostrap: Adding a Month view control
varC="Form-control input-smdatepicker-input";$("input[name = ' _lis_field3 ']"). attr ("class", c); $ (". Datepicker-input"). DateTimePicker ({language:"ZH-CN", Format:"yyyy-mm",//Select the format to fill in the monthAutoClose:true, Minview:" Year", Startview:' Year',//set to Year Month viewtodaybtn:true, Pickerposition:"Bottom-left" });
Scope
Re-declaring variables inside a method can cause variable elevation
var ' Test ' ; (function () { // undefined var'test1' ;
Jquery Digital Operations
Avoid IE8 number anomalies with Parserint (str, in-process)
Under IE8, parseint (' 09 ') Calculates 0,parseint (' 010 ') as 8 instead of 8, 10, which we want. With parseint (' 08 ', 10) that can be converted to normal;
Determine if non-string
if (IsNaN (number (scoreval))) {}
Save 2 digits after the decimal point
B.tofixed (2);
ULR operation
Automatically refreshes the current URL
Window.location.reload ();
URL Jump:
location.href=src+ "? num=" +data+ "&device=" +device1+ "&situation=" +situation1+ "&checkSituation=" + checksituation1;//jump to another page,//can pass other parameters to another page
This window opens another page
window.open (Son_url, "_self");
Get the parameters in the URL
Console.log (WINDOW.LOCATION.SEARCH.SUBSTR (1));//Get the string after the URL?
Get the parameters in the URL by using a regular
VarName =function (name) {varReg =NewREGEXP ("(^|&)"+name +"= ([^&]*) (&|$)"); varR =window.location.search.substr (1). Match (REG); if(r!=NULL)returndecodeURI (r[2]); Returnnull;} Console.log (Name ("Dwname"));
jquery Common operations @ Test sharing