I have a mysql table and I have createDate column in it. I have to send email to the records after every 1 day passed.
For example I have two records and its dates :
2018-04-02 11:04:03
2018-04-04 09:01:45
The first record should get email when every 1 day passed. Hours, minutes are important, too.
For the first record, the dates of email times have to be =>
2018-04-03 11:04
2018-04-04 11:04
2018-04-05 11:04
...
...
...
And For the second record, the dates of email times have to be =>
2018-04-05 09:01
2018-04-06 09:01
2018-04-07 09:01
...
...
How can I handle this situation ?
Thanks all for your answers.
EDIT : I'm changing my question after comments.
I have a dates array.
$dates = ['2018-04-02 11:04:03', '2018-04-04 09:01:45'];
I want a function that will return exactly date difference with currentDate. The cron will work every minute and will check the difference.
<?php
function difference($currentDate, $date){
//will return true if 1 day or 2 days or 3 days etc passed ...
}
$dates = ['2018-04-02 11:04:03', '2018-04-04 09:01:45'];
foreach($dates as $date){
if(difference($currentDate, $date)){
//send email
} else {
//dont send email
}
}