我已经活跃于'并且'活跃于'日期选择器。我可以在设置日期时显示产品信息。
$giftActiveFrom = $_prod->getData('product_gift_active_from');
$giftActiveTo = $_prod->getData('product_gift_active_to');
$timestamp1 = strtotime($giftActiveFrom);
$timeNow = time();
$timestamp2 = strtotime($giftActiveTo);
if(!($timeNow > $timestamp1 && $timeNow < $timestamp2)){
return parent::productAttribute($product, $attributeHtml, $attributeName);
}
即使未设置日期,如何显示产品。也就是说,如果未选择当前激活和激活,我还需要显示产品信息。 帮助!
答案 0 :(得分:0)
如果产品日期/时间未设置/为空,请尝试设置默认时间戳:
$timestamp2 = (!empty(strtotime($giftActiveTo))) ? strtotime($giftActiveTo) : strtotime(date("Y-m-d H:i:s"));