src/Api/User.php
public function lastOnlineDate() : ?\DateTime
    {
        $isOnline = $this->info()->presences[0]->onlineStatus == "online";

        // They're online now, so just return the current DateTime.
        if ($isOnline) return new \DateTime();

        // If they don't have a DateTime, just return null.
        // This can happen if the User object was created using the onlineId string and not the profile data.
        // Sony only provides lastOnlineDate on the 'friends/profiles2' endpoint and not the individual userinfo endpoint.
        // This can be a TODO if in the future Sony decides to make that property available for that endpoint.
        // - Tustin 9/29/2018
        if (!isset($this->info()->presences[0]->lastOnlineDate)) return null;
        
        // I guess it's possible for lastOnlineDate to not exist, but that seems very unlikely.
        return new \DateTime($this->info()->presences[0]->lastOnlineDate);
    }
public function lastOnlineDate() : ?\DateTime
    {
        $isOnline = $this->info()->presences[0]->onlineStatus == "online";

        // They're online now, so just return the current DateTime.
        if ($isOnline) return new \DateTime();

        // If they don't have a DateTime, just return null.
        // This can happen if the User object was created using the onlineId string and not the profile data.
        // Sony only provides lastOnlineDate on the 'friends/profiles2' endpoint and not the individual userinfo endpoint.
        // This can be a TODO if in the future Sony decides to make that property available for that endpoint.
        // - Tustin 9/29/2018
        if (!isset($this->info()->presences[0]->lastOnlineDate)) return null;
        
        // I guess it's possible for lastOnlineDate to not exist, but that seems very unlikely.
        return new \DateTime($this->info()->presences[0]->lastOnlineDate);
    }
public function lastOnlineDate ( ) : ? \ DateTime { $ isOnline = $ this -> info ( ) -> presences [ 0 ] -> onlineStatus == "online" ; // They're online now, so just return the current DateTime. if ( $ isOnline ) return new \ DateTime ( ) ; // If they don't have a DateTime, just return null. // This can happen if the User object was created using the onlineId string and not the profile data. // Sony only provides lastOnlineDate on the 'friends/profiles2' endpoint and not the individual userinfo endpoint. // This can be a TODO if in the future Sony decides to make that property available for that endpoint. // - Tustin 9/29/2018 if ( ! isset ( $ this -> info ( ) -> presences [ 0 ] -> lastOnlineDate ) ) return null ; // I guess it's possible for lastOnlineDate to not exist, but that seems very unlikely. return new \ DateTime ( $ this -> info ( ) -> presences [ 0 ] -> lastOnlineDate ) ; }
Gets the last online date for the User.

@return \DateTime|null
Gets the last online date for the User .