honkmaster Posted June 5, 2015 Share Posted June 5, 2015 Hi, I could do with a bit of help with this, not sure where I'm going wrong. The following code is used to change the colour of a row based on date. I want to compare to todays date with the following results If < today (turns red) if == today (turns orange) if > today (turns green) I have included a screen shot of result I'm getting with below if statement <?php $requireddate = date('l jS F',$row_rsActiveQuotes['quote_requireddate']); //this is anthing before today's date if ($today < $requireddate) { echo '<tr class="tableBody2">'; } //this is anthing with today's date elseif ($today == $requireddate) { echo '<tr class="tableBody3">'; } //this is anthing with today's date elseif ($today > $requireddate) { echo '<tr class="tableBody1">'; } else //this is anthing from tommorow { echo '<tr class="tableBody4">'; } ?> Link to comment https://forums.phpfreaks.com/topic/296652-comparing-dates/ Share on other sites More sharing options...
Barand Posted June 5, 2015 Share Posted June 5, 2015 Dates have to be in yyyy-mm-dd format to perform comparisons Link to comment https://forums.phpfreaks.com/topic/296652-comparing-dates/#findComment-1513228 Share on other sites More sharing options...
honkmaster Posted June 5, 2015 Author Share Posted June 5, 2015 I new that as well, can't see wood for trees sometimes, thanks Link to comment https://forums.phpfreaks.com/topic/296652-comparing-dates/#findComment-1513229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.