Well, after a research I only found this question and a drupal thing.
The question I found is different than mine because their error was to declare the function in an if which is not the case there.
Let's get this straight. I am using an class (classes/Post.php) to display some posts. If I call it, I get this error:
Fatal error: Call to undefined function timeCounting() in C:\xampp\htdocs\classes\Post.php on line 239
Here is my Post.php class (the first function is timeCounting():
<?php
include('./classes/Notify.php');
class Post {
    public static function timeCounting($time_ago)
    {
        $time_ago = strtotime($p['posted_at']);
        $cur_time   = time();
        $time_elapsed   = $cur_time - $time_ago;
        $seconds    = $time_elapsed ;
        $minutes    = round($time_elapsed / 60 );
        $hours      = round($time_elapsed / 3600);
        $days       = round($time_elapsed / 86400 );
        $weeks      = round($time_elapsed / 604800);
        $months     = round($time_elapsed / 2600640 );
        $years      = round($time_elapsed / 31207680 );
        if ($seconds <= 60) {
            return "just now";
        }
        else if ($minutes <= 60) {
            if ($minutes == 1) {
                return  "an minute ago";
            } else {
                return "$minutes minutes ago";
            }
        }
        else if ($hours <= 24) {
            if ($hours == 1) {
                return  "an hour ago";
            } else {
                return "$hours hours ago";
            }
        }
        else if ($days <= 7) {
            if ($days == 1) {
                return  "yesterday";
            } else {
                return "$days days ago";
            }
        }
        else if ($weeks <= 4.3) {
            if ($weeks == 1) {
                return  "a week ago";
            } else {
                return "$weeks weeks ago";
            }
        }
        else if ($months <= 12) {
            if ($months == 1) {
                return  "a month ago";
            } else {
                return "$months months ago";
            }
        }
        else if ($years <= 1) {
            if ($years == 1) {
                return  "a year ago";
            } else {
                return "$years years ago";
            }
        }
        else if ($years >= 10) {
            if ($years == 10) {
                return  "a decade ago";
            } else {
                return "over than a decade ago ($years years)";
            }
        }
    }
    public static function createPost($postbody, $loggedInUserId, $profileUserId) {
            if (strlen($postbody) > 160 || strlen($postbody) < 1) {
                    die('Incorrect length!');
            }
            $topics = self::getTopics($postbody);
            if ($loggedInUserId == $profileUserId) {
                    if (count(Notify::createNotify($postbody)) != 0) {
                            foreach (Notify::createNotify($postbody) as $key => $n) {
                                            $s = $loggedInUserId;
                                            $r = DB::query('SELECT id FROM users WHERE username=:username', array(':username'=>$key))[0]['id'];
                                            if ($r != 0) {
                                                    DB::query('INSERT INTO notifications VALUES (\'\', :type, :receiver, :sender, :extra)', array(':type'=>$n["type"], ':receiver'=>$r, ':sender'=>$s, ':extra'=>$n["extra"]));
                                            }
                                    }
                            }
                    DB::query('INSERT INTO posts VALUES (\'\', :postbody, NOW(), :userid, 0, \'\', :topics)', array(':postbody'=>$postbody, ':userid'=>$profileUserId, ':topics'=>$topics));
            } else {
                    die('Incorrect user!');
            }
    }
    public static function createImgPost($postbody, $loggedInUserId, $profileUserId) {
            if (strlen($postbody) > 160) {
                    die('Incorrect length!');
            }
            $topics = self::getTopics($postbody);
            if ($loggedInUserId == $profileUserId) {
                    if (count(Notify::createNotify($postbody)) != 0) {
                            foreach (Notify::createNotify($postbody) as $key => $n) {
                                            $s = $loggedInUserId;
                                            $r = DB::query('SELECT id FROM users WHERE username=:username', array(':username'=>$key))[0]['id'];
                                            if ($r != 0) {
                                                    DB::query('INSERT INTO notifications VALUES (\'\', :type, :receiver, :sender, :extra)', array(':type'=>$n["type"], ':receiver'=>$r, ':sender'=>$s, ':extra'=>$n["extra"]));
                                            }
                                    }
                            }
                    DB::query('INSERT INTO posts VALUES (\'\', :postbody, NOW(), :userid, 0, \'\', \'\')', array(':postbody'=>$postbody, ':userid'=>$profileUserId));
                    $postid = DB::query('SELECT id FROM posts WHERE user_id=:userid ORDER BY ID DESC LIMIT 1;', array(':userid'=>$loggedInUserId))[0]['id'];
                    return $postid;
            } else {
                    die('Incorrect user!');
            }
    }
    public static function likePost($postId, $likerId) {
            if (!DB::query('SELECT user_id FROM post_likes WHERE post_id=:postid AND user_id=:userid', array(':postid'=>$postId, ':userid'=>$likerId))) {
                    DB::query('UPDATE posts SET likes=likes+1 WHERE id=:postid', array(':postid'=>$postId));
                    DB::query('INSERT INTO post_likes VALUES (\'\', :postid, :userid)', array(':postid'=>$postId, ':userid'=>$likerId));
                    Notify::createNotify("", $postId);
            } else {
                    DB::query('UPDATE posts SET likes=likes-1 WHERE id=:postid', array(':postid'=>$postId));
                    DB::query('DELETE FROM post_likes WHERE post_id=:postid AND user_id=:userid', array(':postid'=>$postId, ':userid'=>$likerId));
            }
    }
    public static function getTopics($text) {
            $text = explode(" ", $text);
            $topics = "";
            foreach ($text as $word) {
                    if (substr($word, 0, 1) == "#") {
                            $topics .= substr($word, 1).",";
                    }
            }
            return $topics;
    }
    public static function link_add($text) {
            $text = explode(" ", $text);
            $newstring = "";
            foreach ($text as $word) {
                    if (substr($word, 0, 1) == "@") {
                            $newstring .= "<a href='profile.php?username=".substr($word, 1)."'>".htmlspecialchars($word)."</a> ";
                    } else if (substr($word, 0, 1) == "#") {
                            $newstring .= "<a href='topics.php?topic=".substr($word, 1)."'>".htmlspecialchars($word)."</a> ";
                    } else {
                            $newstring .= htmlspecialchars($word)." ";
                    }
            }
            return $newstring;
    }
    public static function displayPosts($userid, $username, $loggedInUserId) {
            $dbposts = DB::query('SELECT * FROM posts WHERE user_id=:userid ORDER BY id DESC', array(':userid'=>$userid));
            $username1 = DB::query('SELECT username FROM users WHERE username=:username', array(':username'=>$_GET['username']))[0]['username'];
            $posts = "";
            foreach($dbposts as $p) {
                    if (!DB::query('SELECT post_id FROM post_likes WHERE post_id=:postid AND user_id=:userid', array(':postid'=>$p['id'], ':userid'=>$loggedInUserId))) {
                            $posts .= "<blockquote>   ".self::link_add($p['body'])."<br><a href='".$p['postimg']."'><img class='post' src='".$p['postimg']."'></a><br>"."
                            <form action='profile.php?username=$username&postid=".$p['id']."' method='post'>
                                    <input type='submit' name='like' value='Like'>
                                    <span>".$p['likes']." likes</span>
                            ";
                            if ($userid == $loggedInUserId) {
                                    $posts .= "<input type='submit' name='deletepost' value='delete' />";
                            }
                            $posts .= "
                            </form></blockquote><hr /></br />
                            ";
                    } else {
                            $posts .= "<blockquote> ".self::link_add($p['body'])."<br> <img class='post' src='".$p['postimg']."'>"."
                            <form action='profile.php?username=$username&postid=".$p['id']."' method='post'>
                            <input type='submit' name='unlike' value='unlike'>
                            <span>".$p['likes']." likes</span>
                            ";
                            if ($userid == $loggedInUserId) {
                                    $posts .= "<input type='submit' name='deletepost' value='x' />";
                            }
                            $posts .= "
                            </form></blockquote><hr /></br />
                            ";
                    }
            }
            return $posts;
    }
    public static function displayFosts($userid, $username, $loggedInUserId) {
            $dbposts = DB::query('SELECT posts.id, posts.body, posts.posted_at, posts.postimg, posts.likes, users.`username` FROM users, posts, followers
WHERE posts.user_id = followers.user_id
AND users.id = posts.user_id
AND follower_id = :userid
ORDER BY posts.likes DESC;', array(':userid'=>$userid));
            //$username2 = DB::query('SELECT username FROM users WHERE id=:userid', array(':username'=>$_GET['*']))[0]['username'];
            $posts = "";
            $username = "nope";
            foreach($dbposts as $p) {
                    if (!DB::query('SELECT post_id FROM post_likes WHERE post_id=:postid AND user_id=:userid', array(':postid'=>$p['id'], ':userid'=>$loggedInUserId))) {
                            $posts .= "<blockquote>   ".self::link_add($p['body'])."<br><a href='".$p['postimg']."'><img class='post' src='".$p['postimg']."'></a> <p>".timeCounting($time_ago).
                            $posts .= "</p>
                            </form></blockquote><hr /></br />
                            ";
                    } else {
                            $posts .= "<blockquote> ".self::link_add($p['body'])."<br> <img class='post' src='".$p['postimg']."'>";
                            $time = strtotime($p['posted_at']);
                    }
            }
            return $posts;
    }
}
?>
I really hope the code is not broken.
 
     
    