jotty jotty - 1 year ago 56
PHP Question

How do I check if my dates have a certain year, after retrieving all dates via php?

I am retrieving my date like this in my php query:

DATE_FORMAT(items.r_date, '%M %D, %Y') as r_date

And then displaying it like this, for example:

January 1st, 1934

However, if the year is 1111, I would like to make the date say something custom.

Such as (I know this isn't real code, just trying to explain what I want to do:

if ($row['r_date'] CONTAINS '*1111*') { $r_date = "my custom message"; } else $r_date = $row['r_date'];

Could anyone help me solve this?

Thank you for your time.

Answer Source

Use strpos:

if (false === strpos($row['r_date'], '1111')) { $r_date = $row['r_date']; } else { $r_date = "my custom message"; }