Re: Date Comparison

From: Date: Fri, 28 Aug 2009 14:18:57 +0000
Subject: Re: Date Comparison
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.general 
Request: Send a blank email to php-general+get-297422@lists.php.net to get a copy of this message
2009/8/28 David Stoltz <Dstoltz@shh.org>: > How to I ensure a variable date is not in the past, compared to the > current date? Here's how I'm trying, unsuccessfully: > > $nextdate = "8/2/2009"; > > if(strtotime($nextdate)<=getdate()){ > >        echo "Sorry, your next evaluation date cannot be in the past, > Click BACK to continue."; >        exit; > > } RTFM. The strtotime function will give you a timestamp, getdate will give you an array, so your comparison is non-sensical. Use the time function to get the current date/time as a timestamp. -Stuart -- http://stut.net/

« previous php.general (#297422) next »