timespan() public static method

public static timespan ( integer $timespan ) : string
$timespan integer
return string
Ejemplo n.º 1
0
 /**
  *
  *
  * @throws Exception
  */
 public function ping()
 {
     $start = microtime(true);
     $this->setData('pong', true);
     $this->MasterView = 'empty';
     $this->CssClass = 'Home';
     $valid = true;
     // Test the cache.
     if (Gdn::cache()->activeEnabled()) {
         $k = betterRandomString(20);
         Gdn::cache()->store($k, 1);
         Gdn::cache()->increment($k, 1);
         $v = Gdn::cache()->get($k);
         if ($v !== 2) {
             $valid = false;
             $this->setData('cache', false);
         } else {
             $this->setData('cache', true);
         }
     } else {
         $this->setData('cache', 'disabled');
     }
     // Test the db.
     try {
         $users = Gdn::sql()->get('User', 'UserID', 'asc', 1);
         $this->setData('database', true);
     } catch (Exception $ex) {
         $this->setData('database', false);
         $valid = false;
     }
     $this->EventArguments['Valid'] =& $valid;
     $this->fireEvent('Ping');
     if (!$valid) {
         $this->statusCode(500);
     }
     $time = microtime(true) - $start;
     $this->setData('time', Gdn_Format::timespan($time));
     $this->setData('time_s', $time);
     $this->setData('valid', $valid);
     $this->title('Ping');
     $this->render();
 }