A
A
AlpineMilk2019-04-19 10:49:23
PHP
AlpineMilk, 2019-04-19 10:49:23

How to check the coincidence of dates in a certain period?

There is a date for the set, for example:
2017-07-22 23:59:00 - 2019-04-20 23:59:00
It is stored in the database, when adding a new record, you need to check if the new interval is included in this date and throw a validation error, for example, this record:
2019-04-01 23:59:00 - 2019-04-30 23:59:00
it should cause an error.
I'm just wondering how can I check this? I understand that you need to use one of the Date classes built into php, but I could not find any such example on the Internet, can anyone help me?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
2
2cha.headz, 2019-04-19
@glagolew059

convert dates to unixtime it's easier to compare)
a function for converting to unixtime - then strtotime()
I think everything is simple and does not require explanation

R
Rodion Gashé, 2019-04-19
@zorba_buddha

the range of dates of dates is stored directly in one line or 2 columns date?
if yes - first and then, as above, they wrote through the function
strtotime

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question