我的 Laravel 5.2 代码是
$this->timestamp=date('Y-m-d',intval($timestamp));
$datetime=date('Y/m/d', $timestamp);
Run Code Online (Sandbox Code Playgroud)
date() 期望参数 2 为整数,给定字符串
出现该错误。但是当选择第 31 天而不是其他日期(1 到 30)时会显示该错误。其他日子还好。
当我这样改变我的代码时
$this->timestamp=date('Y-m-d',intval($timestamp));
$datetime=date('Y/m/d', intval($timestamp));
Run Code Online (Sandbox Code Playgroud)
错误已解决,但日期显示不正确。日期总是显示1970/01/01 请帮助我,如何解决这个问题?
小智 5
尝试
$timestamp=date('Y-m-d',"1478774037");
echo $timestamp;
Run Code Online (Sandbox Code Playgroud)
或者
$timestamp=date('Y-m-d',strtotime("31-07-2016"));
echo $timestamp;
Run Code Online (Sandbox Code Playgroud)