0

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

这是我的功能

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 日期

4

0 回答 0