Displaying content based on comparable date values

Hope someone can help with this one.

I am used to using something like this:

<?php if ($row_rsProductA['LastUpdated'] > 0 AND $row_rsProductB['LastUpdated'] > 0) {  ?>
Content to display if Product A and Product B have both been updated.
<?php } ?>

But how can I get it to display content depending on which date value is the most recent?

I tried this:

<?php if ($row_rsProductA['LastUpdated'] < $row_rsProductB['LastUpdated']){ ?>
Content to display if Product A was updated more recently then Product B.
<?php } ?>

But it doesn’t seem to work.

If anyone could post how to achieve this, that would be much appreciated.

Thank you.

1 Like

What datatype are the LastUpdated values and what do they look like?

Seems if they’re like yyyy-mm-dd-hh-mm-ss the conditional should work.

There are TIMESTAMPs, with the form 2015-07-08 18:09:01.

I’ll have another look and see if I can spot anything, typos maybe.

Is it just that the “<” should be a “>”

More recent datetimes will be higher values not lower.

Just to say it was correct all along ( < and > notwithstanding). I had other stuff going on which was preventing it from displaying, but all OK now. Thanks for having a look.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.