1 //Gets the current datetime function in the format "Yyyy-mm-dd hh:mm:ss"2 functiongetnowformatdate (date) {3 if(Date = =NULL) {4 varDate =NewDate ();5 }6 varSeperator1 = "-";7 varSeperator2 = ":";8 varmonth = Date.getmonth () + 1;9 if(Month >= 1 && month <= 9) {Tenmonth = "0" +month; One } A varStrdate =date.getdate (); - if(strdate >= 0 && strdate <= 9) { -Strdate = "0" +strdate; the } - varhour =date.gethours (); - if(Hour >= 0 && hour <= 9) { -hour = "0" +hour; + } - varminute =date.getminutes (); + if(Minute >= 0 && minute <= 9) { Aminute = "0" +minute; at } - varSEC =date.getseconds (); - if(sec >= 0 && sec <= 9) { -SEC = "0" +sec; - } - varcurrentdate = date.getfullyear () + Seperator1 + month +Seperator1 in+ strdate + "" + hour + Seperator2 +minute -+ Seperator2 +sec; to returncurrentdate; +}
Gets the current datetime of the JS function, in the form "Yyyy-mm-dd Hh:mm:ss"