I have in the database stored dates in 2020-12-03 06:00:56
Please tell me how to make a condition and return true
if this date is less or equal to the current
I use Carbon
and Laravel
Answer 1, Authority 100%
very simple
Carbon
copes well with comparisons
$ Date1 = Carbon :: Parse ('2020-12-03 06:00:56');
$ DATE2 = Carbon :: Parse ('2020-12-03 06:00:56');
$ Date3 = Carbon :: Parse ('2020-12-03 06:00:56') - & gt; addminute ();
$ Date4 = Carbon :: Parse ('2020-12-03 06:00:56') - & gt; subminute ();
$ DATE1 == $ DATE2; // True.
$ DATE1- & GT; EQ ($ DATE2); // True.
$ DATE1 & GT; $ DATE3; // false;
$ DATE1 & LT; $ DATE3; // True;
$ DATE1 & GT; $ DATE4; // True.
// It is important to note that the warming goes on microseconds! It means that
Carbon :: Now ()! = Carbon :: Now (); // True.
// T.K. When creating carbon instances, microseconds are taken into account that will be different