![]() |
Comparison Operators >= in Control Structures why false? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Comparison Operators >= in Control Structures why false? (/showthread.php?tid=73280) |
Comparison Operators >= in Control Structures why false? - DELE - 04-07-2019 What am I doing right? PHP Code: $date = '2019-04-07'; My question : PHP Code: $date = '2019-04-07'; RE: Comparison Operators >= in Control Structures why false? - jreklund - 04-07-2019 It's true according to my tests. http://sandbox.onlinephpfunctions.com/code/9674644a817abe76ad0741940e3eaa1905fc9610 RE: Comparison Operators >= in Control Structures why false? - Paradinight - 04-07-2019 PHP is a funny language. https://www.php.net/manual/en/language.operators.comparison.php Use https://www.php.net/manual/en/datetime.diff.php RE: Comparison Operators >= in Control Structures why false? - skunkbad - 04-07-2019 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'; RE: Comparison Operators >= in Control Structures why false? - InsiteFX - 04-07-2019 This should clarify it for you. 'AND' vs '&&' as operator in PHP RE: Comparison Operators >= in Control Structures why false? - DELE - 04-09-2019 (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 RE: Comparison Operators >= in Control Structures why false? - MrJunaidShahid - 04-10-2019 (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. |