我正在尝试比较日期,我有两个给定日期,我想知道当前日期是否在这些给定日期之间。
这是我的功能
private function isDateDiscount($start, $end)
{
$start = new Zend_Date($start);
$end = new Zend_Date($end);
$today = new Zend_Date();
if ($today->isLater($start) && $today->isEarlier($end)){
return true;
} else {
return false;
}
}
我以这种方式在Zend_Db_Table_Row_Abstract扩展中使用此函数:
public function getPrice($withDiscount=false)
{
$price = $this->prezzo;
if (true == $this->isDiscounted() && true == $withDiscount && $this->isDateDiscount($this->inizioSconto, $this->fineSconto)) {
$discount = $this->sconto;
$discounted = ($price*$discount)/100;
$price = round($price - $discounted, 2);
}
return $price;
}
private function isDiscounted()
{
return 0 == $this->sconto ? false : true;
}
值$this->inizioSconto
和$this->fineSconto
在我的数据库中,并且它们是sql Date