SkyRanger Posted January 21, 2008 Share Posted January 21, 2008 Did a search and got totally confused on some posts so I had to post my own. Here is the problem I am having: Client 1 $date = 01-01-2008 Client 2 $date = 02-02-2008 Trying to show clients info before todays date $date = date( 'd-m-Y' ); $futuredate = date("d-m-Y", mktime(0,0,0,date("d"),date("m")+1,date("Y"))); $result = mysql_query( "SELECT * FROM clients where due < '$date'") or die( "Unable to select database"); Trying to show clients info after todays date $result = mysql_query( "SELECT * FROM clients where due >= '$date'") or die( "Unable to select database"); I am having both entries display in both output tables when I only want one in each. Link to comment https://forums.phpfreaks.com/topic/86988-solved-compare-dates/ Share on other sites More sharing options...
The Little Guy Posted January 21, 2008 Share Posted January 21, 2008 Try something like this: <?php $date1 = 01-01-2008 $date2 = 02-02-2008 $p1 = strtotime($date1); $p2 = strtotime($date2); $now = strtotime('now'); if($p1 < $now){ echo $date1; } if($p2 < $now){ echo $date2; } ?> Link to comment https://forums.phpfreaks.com/topic/86988-solved-compare-dates/#findComment-444801 Share on other sites More sharing options...
SkyRanger Posted January 21, 2008 Author Share Posted January 21, 2008 Thanks for the quick reply. Fixed the problem, thanks. Link to comment https://forums.phpfreaks.com/topic/86988-solved-compare-dates/#findComment-444804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.