Welcome Guest, Not a member yet? Register   Sign In
CI4 validation greater_than on date field
#5

@pippuccio76 : You do not need to return the booleans true or false, you can return $date_to_control > $today which evaluates to a boolean.

@InsiteFX :Your code is erroneous InsiteFX. The second parameter of the function doesn't have a $ in front of date2, $date1 > $date2 performs a string comparison not a date comparison and finally applying the ->format method to a string throws a fatal exception. This code is exceedingly error prone. As an aside, whenever you're comparing dates you should use the DateTimeImmutable class rather than DateTime.
Reply


Messages In This Thread
RE: CI4 validation greater_than on date field - by grimpirate - 04-22-2025, 08:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB