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

PHP Code:
// PHP Method to compare dates

// Declare two dates in different
// format and use DateTime() function
// to convert date into DateTime
$date1 = new DateTime("12-11-24");
$date2 = new DateTime("2011-03-26");


// Compare the two dates
if ( ! function_exists('compareDates'))
{
    function compareDates(string $date1string date2): string
    
{
        if ($date1 $date2) {
            return $date1->format("Y-m-d") . " is greater than " $date2->format("Y-m-d");
        } else {
            return $date1->format("Y-m-d") . " is less than " $date2->format("Y-m-d");
        }
    }

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: CI4 validation greater_than on date field - by InsiteFX - 5 hours ago



Theme © iAndrew 2016 - Forum software by © MyBB