根据smarty手册,可以直接使用{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}。但是程序显示。
Warning: date_format() expects parameter 1 to be DateTimeInterface, integer given in E:\PhpStudy20180211\PhpStudy\PHPTutorial\WWW\untitled\templates_c\1ee812ef7e708aabb517e83294d894fcd00dfef1_0.file.test.html.php on line 43
<?php echo date_format(time(),'%Y-%m-%d %H:%M:%S');?>
查看代码原因是time()返回的整数型。dateformat 函数不识别。PHP版本是5.6 手册给的是dateformat 函数识别的是对象。
为了绕过这个问题,采用
date("Y-m-d H:i:s",time())
来绕过这个问题