|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-03-29 22:24 UTC] cmb@php.net
-Package: Feature/Change Request
+Package: Date/time related
[2021-07-30 10:22 UTC] cmb@php.net
-Status: Open
+Status: Wont fix
-Assigned To:
+Assigned To: cmb
[2021-07-30 10:22 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
Description: ------------ I would like to extend the checkdate() function to optionally allow validation of hour/minutes/seconds. Patch: Index: php_date.c =================================================================== RCS file: /repository/php-src/ext/date/php_date.c,v retrieving revision 1.146 diff -u -r1.146 php_date.c --- php_date.c 27 Sep 2007 18:28:38 -0000 1.146 +++ php_date.c 10 Oct 2007 10:14:53 -0000 @@ -1368,20 +1368,29 @@ /* }}} */ -/* {{{ proto bool checkdate(int month, int day, int year) +/* {{{ proto bool checkdate(int month, int day, int year [, int hour, int minute, int second]) Returns true(1) if it is a valid date in gregorian calendar */ PHP_FUNCTION(checkdate) { - long m, d, y; + long m, d, y, h, n, s; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &m, &d, &y) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|lll", &m, &d, &y, &h, &n, &s) == FAILURE) { RETURN_FALSE; } + if (3 != ZEND_NUM_ARGS() && 6 != ZEND_NUM_ARGS()) { + WRONG_PARAM_COUNT; + } + if (y < 1 || y > 32767 || m < 1 || m > 12 || d < 1 || d > timelib_days_in_month(y, m)) { RETURN_FALSE; } - RETURN_TRUE; /* True : This month, day, year arguments are valid */ + + if (6 == ZEND_NUM_ARGS() && (h < 0 || h > 23 || n < 0 || n > 59 || s < 0 || s > 59) { + RETURN_FALSE; + } + + RETURN_TRUE; /* True : This month, day, year arguments are valid and if supplied, so is the hour, minutes and seconds */ } /* }}} */ Also available at http://rquadling.php1h.com/php_date.c_checkdate_supports_time.diff.txt And doc patch is at and assumes a 5.3 change (that's me being hopeful) http://rquadling.php1h.com/checkdate.xml_checkdate_supports_time.diff.txt