If I have a DateTime
interval, such as:
$slot_interval = DateInterval::createFromDatestring('30 minutes');
And another DateTime
object with any date, how can I check that the object fits the interval? So if the interval is 30 min, then dates such as 2016-10-04 12:00:00
and 2016-10-04 14:30:00
would be valid, while 2016-10-04 12:05:10
is not valid anymore?
I could not find many resources for this, except some solutions for MySQL and/or converting dates to unix timestamps, doing division in seconds and checking remainder. Was wondering if there is a nicer and better solution for this?
Thanks!