Creating formatted "[time] [unit] ago" messages from a seconds value
First, here is my recommended replacement for your script (inspired by this SO post) and some test cases:
Code: (Demo)
function secondsToTime($seconds) {
    $dtF = new DateTime('@0');
    $dtT = new DateTime(&quot;@$seconds&quot;);
    $diff = $dtF-&gt;diff($dtT);
    $units = [
        'y' =&gt; 'year',
        'm' =&gt; 'month',
        'd' =&gt; 'day',
        'h' =&gt; 'hour',
        'i' =&gt; 'minute',
        's' =&gt; 'second'
    ];
    foreach ($units as $char =&gt; $unit) {
        if ($diff-&gt;$char) {
            if ($char === 'd' &amp;&amp; $diff-&gt;$char &gt;= 7) {
                $diff-&gt;$char = floor($diff-&gt;$char / 7);
                $unit = 'week';
            }
            return sprintf(
                '%d %s%s ago',
                $diff-&gt;$char,
                $unit,
                $diff-&gt;$char !== 1 ? 's' : ''
            );
        }
    }
}

$tests = [
    53 =&gt;  53,           // y=0, m=0, d=0,  h=0, i=0,  s=53
    365 =&gt; 365,          // y=0, m=0, d=0,  h=0, i=6,  s=5
    7200 =&gt; 7200,        // y=0, m=0, d=0,  h=2, i=0,  s=0
    176455 =&gt; 176455,    // y=0, m=0, d=2,  h=1, i=0,  s=55
    2002000 =&gt; 2002000,  // y=0, m=0, d=23, h=4, i=6,  s=40
    4592000 =&gt; 4592000,  // y=0, m=1, d=22, h=3, i=33, s=20
    66536000 =&gt; 66536000 // y=2, m=1, d=9,  h=2, i=13, s=20
];

var_export(
    array_map('secondsToTime', $tests)
);

Output:
array (
  53 =&gt; '53 seconds ago',
  365 =&gt; '6 minutes ago',
  7200 =&gt; '2 hours ago',
  176455 =&gt; '2 days ago',
  2002000 =&gt; '3 weeks ago',
  4592000 =&gt; '1 month ago',
  66536000 =&gt; '2 years ago',
)

By leveraging the beauty of a PHP DateTime object, you can pick out the largest non-zero unit from the diff() evaluation and do a quick return from the loop/function.  As a bonus, you won't need to worry about daylight savings or leap years or anything -- trust the diff() method.
If you call var_export($diff), you will see that there are additional properties populated, but you only need 6 of them.
I don't think I'd bother with the overhead of a pluralizing function, just write the condition as an inline condition (ternary).
If you want to make $unit a constant, okay, because it won't be mutated.
The only special handling that is necessary is the week calculation because that is not an instantly available property in the object.  Do the simple arithmetic and change the unit to be presented and proceed with returning the desired string.

As for critiquing your code:

$ans is always returned but it is not always declared; I assuming this is a typo that you overlooked.
Your is_plural() condition block is missing its curly braces.
else if as two words in php is a violation of PSR-12 coding standards.  You should form one word as elseif.
I hope that your -1 return is never reached, but if it does then that would suggest that you need to validate your incoming seconds value.