howLongAgo() static public method

多久之前
static public howLongAgo ( $datetime ) : unknown_type
$datetime
return unknown_type
Example #1
0
 function comment()
 {
     \Swoole::$php->session->start();
     if (!$_SESSION['isLogin']) {
         return 'nologin';
     }
     $uid = $_SESSION['user_id'];
     $post['aid'] = (int) $_POST['aid'];
     $post['app'] = $_POST['app'];
     $post['content'] = $_POST['content'];
     $post['uid'] = $uid;
     $post['uname'] = $_SESSION['user']['nickname'];
     if ($post['app'] === 'mblog') {
         $m = createModel('MicroBlog');
         $entity = $m->get($post['aid']);
         $entity->reply_count++;
         $entity->save();
         if ($entity->uid != $uid) {
             App\Api::sendmail($entity->uid, $uid, "【系统】{$post['uname']}评论了你的微博", $post['content']);
         }
     } elseif ($post['app'] === 'blog') {
         $m = createModel('UserLogs');
         $entity = $m->get($post['aid']);
         $entity->reply_count++;
         $entity->save();
         if ($entity->uid != $uid) {
             App\Api::sendmail($entity->uid, $uid, "【系统】{$post['uname']}评论了你的日志.({$entity['title']})", $post['content']);
         }
     }
     createModel('UserComment')->put($post);
     $return = array('id' => $_SESSION['user']['id'], 'addtime' => Swoole\Tool::howLongAgo(date('Y-m-d H:i:s')), 'nickname' => $_SESSION['user']['nickname']);
     if (empty($_SESSION['user']['avatar'])) {
         $return['avatar'] = Swoole::$php->config['user']['default_avatar'];
     } else {
         $return['avatar'] = $_SESSION['user']['avatar'];
     }
     return $return;
 }