kool_samule Posted November 2, 2009 Share Posted November 2, 2009 Hi Chaps, I have a bit of PHP code, that at the moment doesn't work. I'm trying to show all the 'overdue' projects in a different style: <?php if ($row_rsProjects['projdue'] == '= DATE(NOW())') { ?> <tr class="overdue"> <?php } else if ($row_rsProjects['projdue'] == '< DATE(NOW())') { ?> <tr class="duetoday"> <?php } else { ?> <tr class="within"> <?php }?> The '= DATE(NOW())' works with MySQL, but I don't know how to get it to work with PHP. Any ideas? Link to comment https://forums.phpfreaks.com/topic/179976-php-filter-by-date/ Share on other sites More sharing options...
pastcow Posted November 2, 2009 Share Posted November 2, 2009 if ($row_rsProjects['projdue'] == DATE("Y-m-d") should give you the same functionality you might want to check http://php.net/manual/en/function.date.php for more info... Link to comment https://forums.phpfreaks.com/topic/179976-php-filter-by-date/#findComment-949417 Share on other sites More sharing options...
kool_samule Posted November 2, 2009 Author Share Posted November 2, 2009 This is what I've got so far, <?php $today = date("dd/mm/yyyy"); if ($row_rsProjects['projdue_format'] == $today) { ?> <tr class="duetoday"> <?php } else if ($row_rsProjects['projdue_format'] < $today) { ?> <tr class="overdue"> <?php } else if ($row_rsProjects['projdue_format'] > $today) { ?> <tr class="within"> <?php }?> But still isn't working correctly, projects with today's date are showing up as 'overdue' Link to comment https://forums.phpfreaks.com/topic/179976-php-filter-by-date/#findComment-949460 Share on other sites More sharing options...
pastcow Posted November 2, 2009 Share Posted November 2, 2009 $today = date("dd/mm/yyyy"); gives the output 0202/1111/09090909 - you need to make sure you have your date format correct. $today = date("Y-m-d"); will give you 2009-11-02 which is probably what you want to be compatable with mysql. A much better way of doing this would be to use Unix timestamps that are integers. this makes > < and == much simpler. Link to comment https://forums.phpfreaks.com/topic/179976-php-filter-by-date/#findComment-949571 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.