getFuzzyTime() public static method

Gets a slightly more fuzzy time string. such as: yesterday at 3:51pm
public static getFuzzyTime ( integer | string $time, integer $tz_offset = null ) : string
$time integer | string Time
$tz_offset integer optional A timezone offset
return string
Beispiel #1
0
 public function xGetTerminationDetailsAction()
 {
     $this->request->restrictAccess(Acl::RESOURCE_FARMS, Acl::PERM_FARMS_TERMINATE);
     $dbFarm = DBFarm::LoadByID($this->getParam('farmId'));
     $this->user->getPermissions()->validate($dbFarm);
     $dbFarm->isLocked();
     $outdatedFarmRoles = $this->db->GetAll("SELECT id FROM farm_roles WHERE farmid=?", array($dbFarm->ID));
     $data = array();
     $isMongoDbClusterRunning = false;
     $isMysql = false;
     $isRabbitMQ = false;
     foreach ($outdatedFarmRoles as $farmRole) {
         $dbFarmRole = DBFarmRole::LoadByID($farmRole['id']);
         if (!$isMongoDbClusterRunning) {
             $isMongoDbClusterRunning = $dbFarmRole->GetRoleObject()->hasBehavior(ROLE_BEHAVIORS::MONGODB) && $dbFarmRole->GetSetting(Scalr_Role_Behavior_MongoDB::ROLE_CLUSTER_STATUS) != Scalr_Role_Behavior_MongoDB::STATUS_TERMINATED;
         }
         if (!$isMysql) {
             $isMysql = $dbFarmRole->GetRoleObject()->hasBehavior(ROLE_BEHAVIORS::MYSQL);
         }
         if (!$isRabbitMQ) {
             $isRabbitMQ = $dbFarmRole->GetRoleObject()->hasBehavior(ROLE_BEHAVIORS::RABBITMQ);
         }
         $row = array('dtLastSync' => strtotime($dbFarmRole->dtLastSync) ? Scalr_Util_DateTime::getFuzzyTime(strtotime($dbFarmRole->dtLastSync), false) : "Never", 'name' => $dbFarmRole->GetRoleObject()->name, 'id' => $dbFarmRole->ID, 'isBundleRunning' => $this->db->GetOne("\n                    SELECT id FROM bundle_tasks\n                    WHERE status NOT IN ('success','failed')\n                    AND role_id=?\n                    AND farm_id IN (SELECT id FROM farms WHERE client_id=?)\n                 ", array($dbFarmRole->RoleID, $dbFarm->ClientID)));
         foreach ($dbFarmRole->GetServersByFilter(array('status' => SERVER_STATUS::RUNNING)) as $dbServer) {
             $row['servers'][] = array('server_id' => $dbServer->serverId, 'remoteIp' => $dbServer->remoteIp);
         }
         $data[] = $row;
     }
     $this->response->data(array('roles' => $data, 'isMongoDbClusterRunning' => $isMongoDbClusterRunning, 'isMysqlRunning' => $isMysql, 'isRabbitMQ' => $isRabbitMQ, 'farmId' => $dbFarm->ID, 'farmName' => $dbFarm->Name));
 }