CakePHP 中的时间格式化问题 3.x
Time formating troubles in CakePHP 3.x
所以我的约会格式是这样的:
2014-02-15 16:38:30
而且,这就是我尝试格式化它的方式:
<?php echo $this->Time->format('F jS h:i A', $job->created); ?>
错误:
DateTime::__construct(): Failed to parse time string (F jS hh:i A) at
position 5 (h): Double timezone specification
我该如何解决这个双时区问题?
请检查 api TimeHelper 格式函数的正确参数:
http://api.cakephp.org/3.0/class-Cake.View.Helper.TimeHelper.html#_format
如您所见,第一个参数应该是数据,而不是格式。此外,最好只使用日期对象而不是助手,例如:
echo $job->create
控制器按照此处说明的指定格式格式化日期:
http://book.cakephp.org/3.0/en/core-libraries/time.html#formatting
例如你可以做
echo $job->created->nice();
所以我的约会格式是这样的:
2014-02-15 16:38:30
而且,这就是我尝试格式化它的方式:
<?php echo $this->Time->format('F jS h:i A', $job->created); ?>
错误:
DateTime::__construct(): Failed to parse time string (F jS hh:i A) at position 5 (h): Double timezone specification
我该如何解决这个双时区问题?
请检查 api TimeHelper 格式函数的正确参数:
http://api.cakephp.org/3.0/class-Cake.View.Helper.TimeHelper.html#_format
如您所见,第一个参数应该是数据,而不是格式。此外,最好只使用日期对象而不是助手,例如:
echo $job->create
控制器按照此处说明的指定格式格式化日期:
http://book.cakephp.org/3.0/en/core-libraries/time.html#formatting
例如你可以做
echo $job->created->nice();