Zend Date如何检查日期是否在两个给定日期之间

时间:2015-06-20 12:03:20

标签: php date zend-framework zend-date

我正在尝试比较日期,我有两个给定日期,我想知道当前日期是否在这些给定日期之间。

这是我的功能

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

0 个答案:

没有答案