w3resource logo

php.js - checkdate function - php.js Tutorial

php.js : checkdate() function

Secondary Nav


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.




checkdate(month, day, year)


Name Description Required /
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"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<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>
<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 />');

Output of the function

checkdate(12, 12, 1)
checkdate(23, 12, 32767)
checkdate(11, 12, 32768)
checkdate(20, 12, 1)
checkdate(18, 29, 2000)
checkdate(7, 29, 2001)
checkdate(31, 12, 2050)

View example of php.js checkdate() function in browser

Download phpjs.zip

Join our Question Answer community to learn and share your programming knowledge.

Help the community:

PHP: Loop

JavaScript: Delete duplicates in an array

Oracle: Round the number