Several commonly used date functions

zhaozj2021-02-16  44

/ * - Calculate the date of the two characters (YYYY-MM-DD) - * / function date_compare (askDARTDATE, ASENDDATE) {var mistArt = Date.Parse (ASStartDate.Replace (// - / g, ') ')); Var miend = date.parse (// - / g,' / ')); return (MIEND-MISTART) / (1000 * 24 * 3600);

/ * - Judging whether a string (YYY-MM-DD) is correct - * / function date_istrue (asdate) {var lsdate = askate "" "" "; var = lsdate.split (" - "); if (LODATE.LENGTH! = 3) Return False; var liyear = parseint (Lodate [0]); var limonth = parseint (Lidate [1]); var liday = parseint (Lodate [2]); if ((LODATE [0) ] .length> 4) || (LODATE [1] .length> 2) || (Lodate [2] .length> 2)) Return False; if (ISNAN (Liyear) || Isnan (Limonth) || Isnan Liday)) Return False; IF ((Liyear <1900) || (liyear> 3000)) Return False; if ((Limonth> 12) || (Limonth <= 0)) Return False; if (Date_Getday (liyear, Limont

/ * - Return to the number of days of one month - * / function date_getday (aiyear, aimonth) {var loday = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30) , 31]; IF (aiyear% 4 == 0) LODAY [2] = 29; return loday [aimonth];

转载请注明原文地址:https://www.9cbs.com/read-27118.html

New Post(0)