每日笔记

记录击毙


laravel--日常小知识

<p>一、空对象 <code>new \stdClass()</code></p> <h6>二、截取日期:</h6> <pre><code>$coupon-&gt;start_time = strtotime(substr($request-&gt;use_time, 0, 19)); $coupon-&gt;end_time = strtotime(substr($request-&gt;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 &lt;= 2){ $str = sprintf('刚刚', $int); }elseif ($int &lt; 60){ $str = sprintf('%d秒前', $int); }elseif ($int &lt; 3600){ $str = sprintf('%d分钟前', floor($int / 60)); }elseif ($int &lt; 86400){ $str = sprintf('%d小时前', floor($int / 3600)); }elseif ($int &lt; 2592000){ $str = sprintf('%d天前', floor($int / 86400)); }else{ $str = date('Y-m-d H:i:s', $time); } return $str; }</code></pre>

页面列表

ITEM_HTML