php 将分钟前/小时前转为日期

        $startTime = date("Y-m-d H:i:s");
        if(strpos($date,'分钟前') !== false){ 
            $dtime=strstr($date,'分钟前',true);
            $mstr = $dtime>1?' minutes':' minute';
            $tstr= '-'.$dtime.$mstr;
            $date = date('Y-m-d H:i:s',strtotime($tstr,strtotime($startTime)));
           }else if(strpos($date,'小时前') !== false){
            $dtime=strstr($date,'小时前',true);
            $hstr = $dtime>1?' hours':' hour';
            $tstr= '-'.$dtime.$hstr;
            $date = date('Y-m-d H:i:s',strtotime($tstr,strtotime($startTime)));
           }

  

 
posted @ 2023-03-07 11:14  meetrice  阅读(17)  评论(0编辑  收藏  举报