PrestaShop Developer Conference
PrestaShop Developer Conference
Paris, France - November 30, 2023
Let's talk code, commerce and open source.

Warning: You are browsing the documentation for PrestaShop 1.7, which is outdated.

You might want to read an updated version of this page for the current version, PrestaShop 8. Read the updated version of this page

Learn how to upgrade to the latest version.

DateTimeColumn Type

You can use this column type in your Grid to format datetime values. It is common to get datetime values (e.g. Created at, Updated at & etc.) from the database and format them before displaying.

Available options

Properties Type Expected value
field string required The record field name that the column displays.
format string default: Y-m-d H:i:s The format to use when formatting datetime values.

Example usage

use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\DateTimeColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection;

$dateTimeColumn = new DateTimeColumn('datetime');
$dateTimeColumn->setName('Created at');
     'field' => 'date_add',     // the field name that has a datetime value
     'format' => 'Y/d/m H:i:s', // define a custom format for the datetime

$columns = new ColumnCollection();