Jump to content

Compare Dates


honkmaster

Recommended Posts

Hi, Any help would be great

I have the following code which is looking at two dates, due date and today.

<?php[/font][/color][color=#232323][font='Helvetica Neue']
date_default_timezone_set('Europe/London');[/font][/color][color=#232323][font='Helvetica Neue']
$now = time();[/font][/color][color=#232323][font='Helvetica Neue']

if ($row_rsReleaseQue['duedate'] < date('d-m-Y',$now)) {
   echo '<tr class="tableBody3">';
} else {
   echo '<tr class="tableBody1">';
}
?>

I want to change the background colour of the line in my table based on the due date.

< less that todays date = Red (tableBody3)

== equal to today = Orange (tableBody2)

> greater than today = Green (tableBody1)

Cheers Chris

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

Assuming this script is working already, all you need is an else if

 

if ($row_rsReleaseQue['duedate'] < date('d-m-Y',$now)) {
	echo '<tr class="tableBody3">';
} else if($row_rsReleaseQue['duedate'] == date('d-m-Y',$now)) {
	echo '<tr....';
} else {
	echo '<tr class="tableBody1">';
}

Link to comment
https://forums.phpfreaks.com/topic/268929-compare-dates/#findComment-1381866
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.