PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




checkdate

Name

checkdate — Checks a date for numeric validity.

Synopsis

int checkdate(month, day, year);
int month: Number of month
int day: Number of day
int year: Number of year

Returns

TRUE on success; FALSE on failure

Description

Checks whether the given arguments form a valid date. The function allows for months of differing lengths and for leap years. A useful function for checking and validating form input in which a date is required. The allowed range for the year values is 0 to 32767 (inclusive).

Note that you can use mktime() to correct out-of-range dates, if appropriate.

Version

PHP 3, PHP 4

See also

See also getdate() , mkdate() , date() , mktime()

Example

Example 197. Check a date for validity

/* Expected output:
 * 
 * Incorrect date; perhaps you meant March 1, 2001? */
$month = 15;
$day = 1;
$year = 2000;
if (!$date = checkdate($month, $day, $year)) {
    $fixed_time = date('F j, Y', mktime(0, 0, 0, $month, $day, $year));
    print("Incorrect date; perhaps you meant $fixed_time?");
} else {
    print("Date is OK.");
}



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.