Add PHP DateInterval to MySQL value in query

14 Views Asked by At

I want to build a script that check for overdue schedules. Based on the creation date and the interval of the schedule it should get noted as overdue. For example I've created a schedule now, and with an interval of 0 months and 2 days (users can only select months and days). That means in 2 days it's overdue.

In PHP I save it as a DateInterval which is translated into something like this in the database: +P00Y00M02DT00H00M00S. Can I use the value in the database to add that to the creation date (normal MySQL DateTime type)? I am aware of the DATE_ADD function in MySQL but I'm not sure if I can use that.

I was hoping to do all the first checks in pure queries to prevent unnecessary checks in PHP again.

Thanks in advance!

0

There are 0 best solutions below