Re: DateTime wierdness

From: Date: Thu, 29 Mar 2012 18:39:09 +0000
Subject: Re: DateTime wierdness
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-317350@lists.php.net to get a copy of this message
2012/3/29 Martín Marqués <martin.marques@gmail.com>: > El día 29 de marzo de 2012 14:14, David OBrien <dgobrien@gmail.com> escribió: >> actually this would work well ... compare what they send with the output of >> the formatdate >> >> function checkDateTime($data) { >>     if (date('Y-m-d H:i:s', strtotime($data)) == $data) { >>         return true; >>     } else { >>         return false; >> >>     } >> } > > Well, I did somethin similar... > >    $arDate = explode("/", $nacimiento); >    if(!checkdate($arDate[1], $arDate[0], $arDate[2])) >      $nacimiento = ''; > > Just need to set the variable $nacimiento to the empty string if it's > not a valid date. > > Thanks anyway, > > > -- > Martín Marqués > select 'martin.marques' || '@' || 'gmail.com' > DBA, Programador, Administrador > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I don't know how it came to be, but a lot of people rely on this behaviour. It does make sense if you squint at it a bit -- trust that the programmer meant what they said and deliver something useful, leave error checking up to the programmer. I'm a bit ambivalent about it, personally, but the way it's implemented does seem more flexible.

« previous php.general (#317350) next »