The
is similar to the checkdate in PHP.
Function Name: Checkdatetime//Feature Description: Check for date time function Checkdatetime (str) {var reg =/^ (\d+)-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{
1,2}):(\d{1,2}) $/;
var r = Str.match (reg);
if (r==null) return false;
R[2]=r[2]-1;
var d= new Date (r[1], r[2],r[3], r[4],r[5], r[6]);
if (D.getfullyear ()!=r[1]) return false;
if (D.getmonth ()!=r[2]) return false;
if (D.getdate ()!=r[3]) return false;
if (D.gethours ()!=r[4]) return false;
if (D.getminutes ()!=r[5]) return false;
if (D.getseconds ()!=r[6]) return false;
return true; /** determine the date format entered in the input box is YYYY-MM-DD and the correct date/function IsDate (sm,mystring) {var reg =/^ (\d{4})-(\d{2})-(\d{2}) $/; var str =
MyString
var arr = reg.exec (str);
if (str== "") return true; if (!reg.test (str) &®exp.$2<=12&®exp.$3<=31) {alert ("Please ensure that +sm+"
The date format entered in is YYYY-MM-DD or the correct date! ");
return false;
return true; } function todatefromstring (strdate) {if (Strdate.length!= 8) {return null;} var dtdate = null; var nyear = par
Seint (strdate.substring (0, 4), 10); var nmonth = ParseiNT (Strdate.substring (4, 6), 10);
var nday = parseint (strdate.substring (6, 8), 10); if (isNaN (nyear) = = True | | | isNaN (nmonth) = = True | | isNaN (nday) = = true) {return null;} dtdate = new Date (Nyea
R, NMonth-1, Nday); if (nyear!= dtdate.getfullyear () | | (nMonth-1)!= dtdate.getmonth () | |
Nday!= dtdate.getdate ()) {return null;} return dtdate; Format of YYYYMMDD
Above this JS to determine whether the date format is a simple example is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.