php.js : checkdate() function
checkdate() function
The checkdate() is used to validate a date in the Gregorian calendar. Return true for a valid date, otherwise false.
Note : The Gregorian calendar is the internationally accepted civil calendar. It was introduced by Pope Gregory XIII, after whom the calendar was named.
Version
1103.1210
Syntax:
checkdate(month, day, year)
Parameters:
Name | Description | Required / Optional |
Type |
---|---|---|---|
month | The month is from 1 to 12. | Required | Integer |
day | Number of days of a month. Leap years are taken into consideration. | Required | Integer |
year | The range of the year : From 1 to 32767. | Required | Integer |
Example of php checkdate() function.
In the following web document we check various date format compatible with the gregorian date. If the date matchs it returns true otherwise false.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>php.js : checkdate() function example</title>
<script type="text/javascript" src="../../phpjs/date/datetime.min.js"> </script>
</head>
<body>
<h1 style="color: green">php.js : checkdate() function example</h1>
<h3>Various date format compatible with Gregorian date</h3>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
document.write('checkdate(12, 12, 1)'+"<br />");
document.write(checkdate(12, 12, 1)+"<br />");
document.write('checkdate(23, 12, 32767)'+'<br />');
document.write(checkdate(23, 12, 32767)+'<br />');
document.write('checkdate(11, 12, 32768)'+'<br />');
document.write(checkdate(11, 12, 327687)+'<br />');
document.write('checkdate(20, 12, 1)'+'<br />');
document.write(checkdate(20, 12, 1)+'<br />');
document.write('checkdate(18, 29, 2000)'+'<br />');
document.write(checkdate(18, 29, 2000)+'<br />');
document.write('checkdate(7, 29, 2001)'+'<br />');
document.write(checkdate(7, 29, 2001)+'<br />');
document.write('checkdate(31, 12, 2050)'+'<br />');
document.write(checkdate(31, 12, 2050)+'<br />');
//]]>
</script>
</body>
</html>
Output of the function:
.checkdate(12, 12, 1) true checkdate(23, 12, 32767) false checkdate(11, 12, 32768) false checkdate(20, 12, 1) false checkdate(18, 29, 2000) false checkdate(7, 29, 2001) true checkdate(31, 12, 2050) false
View example of php.js checkdate() function in browser
Previous: php.js Tutorial
Next:
php.js: date() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/phpjs/date/checkdate.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics