我正在使用 CakePHP 3.2。
我想将timestamp
数据库中的日期与isThisMonth()
CakePHP 的功能进行比较。
我正在列出created
日期在 内的产品1 month
。它将显示NEW
带有产品的徽章。
这就是我所做的
<?php $date = new DateTime($product->created);
$date = $date->format('Y-m-d');
if ($date->isThisMonth()): ?> // error is pointing this line
<span class="new-product"> NEW</span>
<?php endif; ?>
这$product
是一个错误项,created
是数据库中的时间戳列。
但这给出了错误
Call to a member function isThisMonth() on string