Comparison Operators >= in Control Structures why false? |
What am I doing right?
PHP Code: $date = '2019-04-07'; My question : PHP Code: $date = '2019-04-07';
It's true according to my tests.
http://sandbox.onlinephpfunctions.com/co...1905fc9610
PHP is a funny language.
https://www.php.net/manual/en/language.o...arison.php Use https://www.php.net/manual/en/datetime.diff.php
PHP has no way of knowing that your dates are dates. There are a number of ways you could handle it, but the simplest would be to wrap your dates in strtotime()
PHP Code: $date = '2019-04-07';
This should clarify it for you.
'AND' vs '&&' as operator in PHP What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(04-07-2019, 08:43 AM)skunkbad Wrote: PHP has no way of knowing that your dates are dates. There are a number of ways you could handle it, but the simplest would be to wrap your dates in strtotime() SOLVED. THANK YOU FOR HELPING
(04-07-2019, 08:43 AM)skunkbad Wrote: PHP has no way of knowing that your dates are dates. There are a number of ways you could handle it, but the simplest would be to wrap your dates in strtotime() You are exactly right, in the top when defining the date it is the string and when we compare any string resultant will be true always. In only case if it is integer or date in right format then we can compare.
.NET and CodeIgniter Software Engineer
|
Welcome Guest, Not a member yet? Register Sign In |