Jump to content

comparing dates


honkmaster

Recommended Posts

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">'; 
 	}
 	?>

post-90840-0-86550300-1433485583_thumb.png

Link to comment
https://forums.phpfreaks.com/topic/296652-comparing-dates/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.