public static function secondsToText($seconds, $returnAsWords = false)
    {
        $periods = [
            'year'   => 3.156e+7,
            'month'  => 2.63e+6,
            'week'   => 604800,
            'day'    => 86400,
            'hour'   => 3600,
            'minute' => 60,
            'second' => 1,
        ];

        $parts = [];
        foreach ($periods as $name => $dur) {
            $div = floor($seconds / $dur);

            if ($div == 0) {
                continue;
            }

            if ($div == 1) {
                $parts[] = ($returnAsWords ? self::numberToWord($div) : $div).' '.$name;
            } else {
                $parts[] = ($returnAsWords ? self::numberToWord($div) : $div).' '.$name.'s';
            }

            $seconds %= $dur;
        }

        $last = array_pop($parts);

        if (empty($parts)) {
            return $last;
        }

        return implode(', ', $parts).' and '.$last;
    }