note 65239 added to function.getdate
| From: | king_of_t3rrors at hotmail dot com | Date: | Thu, 27 Apr 2006 12:12:54 +0000 |
| Subject: | note 65239 added to function.getdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-109852@lists.php.net to get a copy of this message | ||
This is a correction of the note posted on 27-Feb-2006 03:29:
"Simple routine for determining whether some date given
in MySQL format (yyyy-mm-dd) has gone past."
I think that code was wrong.
My code is:
function is_past( $date,$format )
// When calling this function remember:
// $date format: yyyy-mm-dd
// $format--> insert 'ymd' as second argument
{
$today = getdate() ;
$datebits=explode('-',$date);
$year = intval($datebits[strpos($format, 'y')]);
$mon = intval($datebits[strpos($format, 'm')]);
$today = intval($datebits[strpos($format, 'd')]);
if ( $today['year'] > $year ) {
return false ;
}
if ( $today['mon'] > $mon ) {
return false;
}
if ( $today['mday'] > $today ) {
return false;
}
return true;
}
----
Server IP: 130.206.1.5
Probable Submitter: 83.42.176.141
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.getdate.php
Edit -- http://master.php.net/note/edit/65239
Del: integrated -- http://master.php.net/note/delete/65239/integrated
Del: useless -- http://master.php.net/note/delete/65239/useless
Del: bad code -- http://master.php.net/note/delete/65239/bad+code
Del: spam -- http://master.php.net/note/delete/65239/spam
Del: non-english -- http://master.php.net/note/delete/65239/non-english
Del: in docs -- http://master.php.net/note/delete/65239/in+docs
Del: other reasons-- http://master.php.net/note/delete/65239
Reject -- http://master.php.net/note/reject/65239
Search -- http://master.php.net/manage/user-notes.php