RE: [PHP-DB] -14 Days Ago

From: Date: Fri, 08 Oct 2004 19:19:03 +0000
Subject: RE: [PHP-DB] -14 Days Ago
Groups: php.db 
Request: Send a blank email to php-db+get-36702@lists.php.net to get a copy of this message
That's probably the best way to go, but if you wanted another way: $mySqlDate = "20041008"; $month = substr($mySqlDate,4,2); $day = substr($mySqlDate,6,2); $year = substr($mySqlDate,0,4); $mySqlDateSerial = mktime(0,0,0,$month,$day,$year); $twoWeeksAgoSerial = mktime(0,0,0,date("m"),date("d")-14,date("Y")); If ($mySqlDateSerial < $twoWeeksAgoSerial) { echo "<h5>Assignment In Void:</h5><br><h4>Assignments in the void are read-only"; require('footer.php'); exit; } But I always do things the hard way. Haha. -TG > -----Original Message----- > From: Wendell Frohwein [mailto:wendell@3rdpixel.com] > Sent: Friday, October 08, 2004 2:57 PM > To: 'Cole S. Ashcraft'; php-db@lists.php.net > Subject: RE: [PHP-DB] -14 Days Ago > > > You can trying using the MySQL DATE_ADD() , DATE_SUB , and NOW() > functions. > > > -wendell frohwein > > -----Original Message----- > From: Cole S. Ashcraft [mailto:csa@ashcraftfamily.net] > Sent: Friday, October 08, 2004 11:36 AM > To: php-db@lists.php.net > Subject: [PHP-DB] -14 Days Ago > > I am trying to see whether a data in an array pulled from a MySQL DB > (YEARMONTHDATE) is older than 14 days ago. I am trying to do this in > PHP. My code looks like: > > if($array['due'] <= $today - 14) > { > echo "<h5>Assignment In Void:</h5><br><h4>Assignments in the void > are > read-only"; > require('footer.php'); > exit; > }. > > I am having problems with the math. How do I do a date subtraction > without ending up with something like 20040994 (not a valid date)? > > Thanks, > Cole

« previous php.db (#36702) next »