Documentation

CompareDates

int
CDatabase::CompareDates(
 string date1,
 string date2,
)

Compares two dates. Return values:

Condition Return value
date1 > date2 1
date1 < date2 -1
date1 = date2 0

Non-static method.

Parameters

ParameterDescription
date1 First date to be compared.
date2 Second date to be compared.

See Also

Examples of use

<?
// set date 1
$date1 = "01.01.2005";

// set date 2
$date2 = "01.01.2006";

$result = $DB->CompareDates($date1, $date2); 

if ($result==1) echo $date1." > ".$date2;
elseif ($result==-1) echo $date1." < ".$date2;
elseif ($result==0) echo $date1." = ".$date2;
?>


© «Bitrix24», 2001-2024