I have a CRON job set to run every hour (have to do it this often due to scheduling facilities on server) and one of the sections of the script is to check if a closing date for entries into an event is within 2 days and if so to email a reminder for payment to those who have not yet paid. When I tested it it seemed to work but a closing date is tomorrow and the emails didn't go out yesterday. I am looking for suggestions on how I can get this to work.

My current if statement is

if ($result['show_closing'] == date('Y-m-d', strtotime('+2 days'))) { // send email and updated the customer fes record to indicate that a reminder has been sent so it only does it once

The date is stored as date format in the database YYYY-MM-DD.

Any ideas please?

You could check if the date is <=

Thank you, that has made me wonder whether I would be best doing a less than and greater than comparison - will have a play.

What about:

if ($result['show_closing'] > date('Y-m-d', strtotime('+1 days')) && $result['show_closing'] < date('Y-m-d', strtotime('+3 days'))) {

Would this work?

Yes that works. Less than 3 also means 2 days and 23 hours, if your column is a datetime. Not sure if that's what you want.

Lets hope so - have yet to test it. I only have date for the column, not datetime as it is not required.

By the way this is all working now, thanks for the help