错误的博客发布日期显示在Magento
我在magento的前端发现错误的博客发布日期。错误的博客发布日期显示在Magento
这是我的帖子的phtml文件的代码。
$formatType = Mage::getStoreConfig(NeoTheme_Blog_Helper_Data::XPATH_CONFIG_DATETIME_FORMAT_TYPE);
$format = ($formatType != 'custom')?
Mage::app()->getLocale()->getDateTimeFormat($formatType):
Mage::getStoreConfig(NeoTheme_Blog_Helper_Data::XPATH_CONFIG_DATETIME_CUSTOM_FORMAT);
,并在下面HTML它显示日期一样 -
<span class="post-time">
<?php //echo $this->__('Posted On: '); ?>
<?php $date = ($this->getPost()->getPostDate() != NULL)? $this->getPost()->getPostDate() : $this->getPost()->getCreatedAt(); ?>
<?php echo Mage::app()->getLocale()->date($date)->toString($format); ?>
<?php // $timestamp = (int) Mage::app()->getLocale()->date($date)->getTimestamp() ;?>
<?php // echo date('d D', $timestamp)?><?php // echo date('M', $timestamp)?>
</span>
这是我的数据库结构
+--------------------+----------------------+------+-----+---------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+----------------------+------+-----+---------------------+-----------------------------+
| entity_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| created_at | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| updated_at | timestamp | NO | | 0000-00-00 00:00:00 | |
| status | smallint(5) unsigned | NO | | 1 | |
| title | text | NO | | NULL | |
| author | text | NO | | NULL | |
| post_date | timestamp | NO | | 0000-00-00 00:00:00 | |
| summary | text | NO | | NULL | |
| content_html | text | NO | | NULL | |
| meta_description | text | YES | | NULL | |
| meta_title | text | YES | | NULL | |
| meta_keywords | text | YES | | NULL | |
| store_ids | text | NO | | NULL | |
| category_ids | text | NO | | NULL | |
| tag_ids | text | NO | | NULL | |
| cms_identifier | varchar(255) | YES | UNI | NULL | |
| customer_group_ids | text | YES | | NULL | |
| publish_date | timestamp | YES | | NULL | |
| use_summary | smallint(6) | YES | | 1 | |
| root_template | varchar(255) | YES | | NULL | |
| layout_update_xml | text | YES | | NULL | |
+--------------------+----------------------+------+-----+---------------------+-----------------------------+
谁能帮我找到什么是错,此代码。 在数据库中显示正确的日期。
有两件事你必须
先上更新CURRENT_TIMESTAMP
删除此所以,如果你想要做的Magento方式的日期将不会更新
使用此为created_At Varien_Date::now()
设定值。
<?php $date=Mage::app()->getLocale()->date($date);
echo date('L d, M Y',strtotime($date)) ?>
如何转换此日期' getLocale() - > date($ date); ?> 2015年12月22日上午12:48:42'喜欢这个'2016年7月14日星期四' –
更新了答案 –
它什么也没有显示。当我添加你的代码时,实际上页面什么也没有显示我写了这个代码' formatDate($ date,Mage_Core_Model_Locale :: FORMAT_TYPE_FULL,false); ?>'但它显示这样的输出'2015年12月22日星期二'如何更改为'2015年12月22日星期二' –
你检查你的本地设置的时间在'系统>配置区域设置选项>一般本地option'它是正确的 –
是的,它是按照我的理解EST时区(美国纽约) –
在数据库中保存正确'EST时区(美国纽约)'? –