<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Validate a Gregorian date</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.datetime.html">Date/Time Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.date-add.html">date_add</a></div> <div class="up"><a href="ref.datetime.html">Date/Time Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.checkdate" class="refentry"> <div class="refnamediv"> <h1 class="refname">checkdate</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">checkdate</span> — <span class="dc-title">Validate a Gregorian date</span></p> </div> <div class="refsect1 description" id="refsect1-function.checkdate-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>checkdate</strong></span> ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$month</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$day</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$year</code></span> )</div> <p class="para rdfs-comment"> Checks the validity of the date formed by the arguments. A date is considered valid if each parameter is properly defined. </p> </div> <div class="refsect1 parameters" id="refsect1-function.checkdate-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">month</code></em></span> <dd> <p class="para"> The month is between 1 and 12 inclusive. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">day</code></em></span> <dd> <p class="para"> The day is within the allowed number of days for the given <em><code class="parameter">month</code></em>. Leap <em><code class="parameter">year</code></em>s are taken into consideration. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">year</code></em></span> <dd> <p class="para"> The year is between 1 and 32767 inclusive. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.checkdate-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> if the date given is valid; otherwise returns <strong><code>FALSE</code></strong>. </p> </div> <div class="refsect1 examples" id="refsect1-function.checkdate-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-2292"> <p><strong>Example #1 <span class="function"><strong>checkdate()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">checkdate</span><span style="color: #007700">(</span><span style="color: #0000BB">12</span><span style="color: #007700">, </span><span style="color: #0000BB">31</span><span style="color: #007700">, </span><span style="color: #0000BB">2000</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">checkdate</span><span style="color: #007700">(</span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">29</span><span style="color: #007700">, </span><span style="color: #0000BB">2001</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> bool(true) bool(false) </pre></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.checkdate-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.mktime.html" class="function" rel="rdfs-seeAlso">mktime()</a> - Get Unix timestamp for a date</span></li> <li class="member"> <span class="function"><a href="function.strtotime.html" class="function" rel="rdfs-seeAlso">strtotime()</a> - Parse about any English textual datetime description into a Unix timestamp</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.datetime.html">Date/Time Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.date-add.html">date_add</a></div> <div class="up"><a href="ref.datetime.html">Date/Time Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>