<span id="pfnzv"></span>
      <form id="pfnzv"><span id="pfnzv"></span></form><address id="pfnzv"><span id="pfnzv"><nobr id="pfnzv"></nobr></span></address>
      <form id="pfnzv"><dfn id="pfnzv"><listing id="pfnzv"></listing></dfn></form>

        <sub id="pfnzv"><address id="pfnzv"></address></sub>
          <address id="pfnzv"><form id="pfnzv"><listing id="pfnzv"></listing></form></address>
          <address id="pfnzv"><address id="pfnzv"><nobr id="pfnzv"></nobr></address></address>

            <address id="pfnzv"></address>
            0712-2888027 189-8648-0214
            微信公眾號

            孝感風信網絡科技有限公司微信公眾號

            當前位置:主頁 > 技術支持 > PHP > php根據當前用戶信息時間顯示時間狀態的代碼片段

            php根據當前用戶信息時間顯示時間狀態的代碼片段

            時間:2024-06-05來源:風信官網 點擊: 593次
            php根據當前用戶信息時間顯示時間狀態的代碼片段,以下代碼為項目開發中的片段,實現方法思路僅供參考。
            <?php
            
            $created_at = !empty($v->created_at) ? $v->created_at : $v->created_at_as;
            $time_differents = time() - strtotime($created_at);
            $time_differents = round($time_differents/3600, 3);
            //返回當前時間狀態
            switch ($time_differents) {
                case $time_differents <= 0.033:
                    $data[$k]->visit_time = '剛剛';
                    break;
                
                case $time_differents <= 0.033 && $time_differents < 1:
                    $data[$k]->visit_time = round($time_differents*60, 0).'分鐘前';
                    break;
            
                case $time_differents <= 1 && $time_differents < 24:
                    $data[$k]->visit_time = round($time_differents).'小時前';
                    break;
            
                case $time_differents <= 24 && $time_differents < 48:
                    $data[$k]->visit_time = '昨天';
                    break;
            
                case $time_differents <= 48 && $time_differents < 72:
                    $data[$k]->visit_time = '2天前';
                    break;
            
                case $time_differents <= 72 && $time_differents < 96:
                    $data[$k]->visit_time = '3天前';
                    break;
            
                case $time_differents <= 96 && $time_differents < 120:
                    $data[$k]->visit_time = '4天前';
                    break;
            
                case $time_differents <= 120 && $time_differents < 144:
                    $data[$k]->visit_time = '5天前';
                    break;
            
                case $time_differents <= 144 && $time_differents < 168:
                    $data[$k]->visit_time = '6天前';
                    break;
            
                case $time_differents <= 168 && $time_differents < 336:
                    $data[$k]->visit_time = '1周前';
                    break;
            
                default:
                    # code...
                    break;
            }
            
            欄目列表
            推薦內容
            熱點內容
            展開
            国产精久久久久无码AV动漫|最新亚洲精品国偷自产在线|2021亚洲色中文字幕在线|最新无码av中文字专区 情欲美妇紧致敏感 国产免费AⅤ片在线播放 人妻爽爽免费在线视频 51精品国产人成在线观看 色偷偷av一区二区三区
            <span id="pfnzv"></span>
                <form id="pfnzv"><span id="pfnzv"></span></form><address id="pfnzv"><span id="pfnzv"><nobr id="pfnzv"></nobr></span></address>
                <form id="pfnzv"><dfn id="pfnzv"><listing id="pfnzv"></listing></dfn></form>

                  <sub id="pfnzv"><address id="pfnzv"></address></sub>
                    <address id="pfnzv"><form id="pfnzv"><listing id="pfnzv"></listing></form></address>
                    <address id="pfnzv"><address id="pfnzv"><nobr id="pfnzv"></nobr></address></address>

                      <address id="pfnzv"></address>