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


i retrieving date in php query:

date_format(items.r_date, '%m %d, %y') r_date 

and displaying this, example:

january 1st, 1934 

however, if year 1111, make date custom.

such (i know isn't real code, trying explain want do:

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

could me solve this?

thank time.

a literal implementation of pseudo-code uses strpos:

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

however, "only check last 4 digits" answer dagon, or alternate 1 below using substr_compare, may yield fewer false positives:

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

note i've used trim here in event date has spurious white-space on end.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -