Re: Comparing dates in text files

From: Date: Sat, 01 Jul 2000 22:41:25 +0000
Subject: Re: Comparing dates in text files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-4315@lists.php.net to get a copy of this message
In article <8jaknm$bgf$1@toye.php.net>, fn@csh.rit.edu ("C. Marcera") wrote: > Hello, > I have a bunch of text files that have the date on the second line. I > also have a set of search criteria... a start month/day/year and an end > month/day/year. How can I tell if the date of that text file lies between my > two search dates? Is there any function that can compare dates besides > checkdate (I don't think that will work here...?)? I tried comparing the > actual file date but the files can be edited so that date changes. I'm > really stuck on this one... any help would be great! $date1 = '07/01/2000'; $date2 = '08/01/2000'; $date1parts = explode('/', $date1); $date2parts = explode('/', $date2); $date1int = mktime(0, 0, 0, $date1parts[0], $date1parts[1], $date1parts[2]); $date2int = mktime(0, 0, 0, $date2parts[0], $date2parts[1], $date2parts[2]); $now = time(); if ($date1int <= $now && $now <= $date2int){ echo "Current<BR>\n"; } elseif ($date1int > $now){ echo "Past<BR>\n"; } else{ echo "Future<BR>\n"; } -- Richard Lynch | If this was worth $$$ to you, buy a CD US Customer Support Director | from one of the artists listed here: Zend Technologies USA | http://www.L-I-E.com/artists.htm http://www.zend.com | (this has nothing to do with Zend, duh!)

« previous php.general (#4315) next »