Bitrix Site Manager

CDatabase::CompareDates

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

The method CompareDates compares two dates.

Parameters

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

Return Values

The method returns the following values.

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

See Also

Example



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

// date 2
$date2 = "01.01.2007";

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

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