使用 Magento 转换 SQL 时间戳以使用 PHP 格式


Converting SQL Timestamp With Magento To Use PHP Formatting

假设我的实体表包含一个created_at列。在调用实体创建的时间时,我会执行以下操作:

$entity = Mage::getModel('namespace/entity')->load(1);
//and if I want the time it was created at I would do
$created = $entity->getCreatedAt();

问题是,这返回了一个丑陋的时间戳,在许多情况下对前端用户不是很有用。示例时间戳:2013-10-25 14:00:28

为时间戳提供格式以使其用户可读的最佳方法是什么。

这就是我如何格式化日期:

$output_date = date('d-m-Y', Mage::getModel('core/date')->timestamp($entity->getCreatedAt()));