Jump to content

Comparing 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 date_default_timezone_set('Europe/London');$now = time();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
Share on other sites

you should use timestamp to compare dates. first calculate the current day timestamp range. use mktime() to get timestamp certain date of 00 hour 00minutes 00 seconds (when day starts) and now get timestamp of $row_rsReleaseQue['duedate']. if current timestamp is greater than the DB timsetamp, then due date has not come yet.if current timestam less than DB timstamp either due date is today or due dat has been passed. to check if it is due date or due date passed, substract current timestamp and DB timestamp if it is greater than 86400 due date has passed else today is duedate

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...