2016-07-13 15 views
0

私はCakePHP 3.2で作業しています。CakePHP 3:ビューの日付比較

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は、データベース内のタイムスタンプ列です。

しかし$date = $date->format('Y-m-d');

$time = new Time($date); 

の下にこれを追加すること

Call to a member function isThisMonth() on string 

答えて