laravel--日常小知识
<p>一、空对象 <code>new \stdClass()</code></p>
<h6>二、截取日期:</h6>
<pre><code>$coupon->start_time = strtotime(substr($request->use_time, 0, 19));
$coupon->end_time = strtotime(substr($request->use_time, 22));</code></pre>
<p>三、linux时间戳转换成刚刚之类</p>
<pre><code>function wordTime($time) {
$time = (int) substr($time, 0, 10);
$int = time() - $time;
$str = '';
if ($int <= 2){
$str = sprintf('刚刚', $int);
}elseif ($int < 60){
$str = sprintf('%d秒前', $int);
}elseif ($int < 3600){
$str = sprintf('%d分钟前', floor($int / 60));
}elseif ($int < 86400){
$str = sprintf('%d小时前', floor($int / 3600));
}elseif ($int < 2592000){
$str = sprintf('%d天前', floor($int / 86400));
}else{
$str = date('Y-m-d H:i:s', $time);
}
return $str;
}</code></pre>