From: friendica Date: Sun, 2 Dec 2012 21:47:41 +0000 (-0800) Subject: bug #511 - if birth year supplied but not a month or day, force a sane default. PHP... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=79fb5509ed623d2f2f648d26afa5cae2ab092444;p=friendica.git bug #511 - if birth year supplied but not a month or day, force a sane default. PHP datetime functions don't handle zero very well. --- diff --git a/mod/profiles.php b/mod/profiles.php index e30c982182..d4a3db83e0 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -42,6 +42,13 @@ function profiles_post(&$a) { $day = intval($_POST['day']); if(($day > $mtab[$month]) || ($day < 0)) $day = 0; + + // It's OK to have an empty (0) year, but if you supplied a year you have to have a non-zero month and day + if($year && ! $month) + $month = 1; + if($year && ! $day) + $day = 1; + $dob = '0000-00-00'; $dob = sprintf('%04d-%02d-%02d',$year,$month,$day);