G
G
grenline1231232021-06-30 20:09:09
PHP
grenline123123, 2021-06-30 20:09:09

How to update the date one month ahead?

$sql = "SELECT * FROM Discounts";
$currDate = date('d-m-y h:i:s');

foreach($dbh->query($sql) as $row) {
    if($row['time'] < $currDate) {

    }
}

I need to check every midnight whether some promotion has ended, if it has ended, then I need to renew it for a month in advance, that is, if it ended on 06/30/2021 23:23:23, then it will be updated to 07/30/2021 using the script 23 :23:23.
I have no idea how to implement it correctly, I thought about somehow separating it, so far nothing has worked out

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2021-06-30
@rozhnev

UPDATE Discounts SET time = DATE_ADD(time, INTERVAL 1 MONTH) WHERE time < NOW();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question