date("t")
| From: | Maurice Rickard | Date: | Fri, 19 Jan 2001 03:34:42 +0000 |
| Subject: | date("t") | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-35552@lists.php.net to get a copy of this message | ||
I know I can get the number of days in the current month with date("t"), but how would I go about getting the number of days in a different month?
I have a form that allows users to insert a date. If the value they put in doesn't exist (February 31, 2001, for example), I want to override it. I'm already using checkdate to determine if a date is bad, but I'm a bit stumped on using date("t") to set a valid maximum for the month the user submits. (I've set up the form so that users will always submit a valid month, but the day is my one loose end.)
Here's my code, if you'd like to make suggestions:
$ver_date = checkdate($date_month, $date_day, $date_year);
if ($ver_date) {
$safedate = $date_year."-".$date_month."-".$date_day;
} else {
//reset their date_day somehow
}
Thanks for any suggestions,
Maurice
--
Maurice Rickard
http://mauricerickard.com/