phplaravellaravel-7

Undefined Function bcsub()


Im Using This Code In my Local Laravel and in success

public function dateForHuman($custom_timestamp) 
  {
        $date = bcsub($custom_timestamp, 25569, 10) * 86400;
        return date('Y-m-d H:i:s', $date);
  }

but When i try in my server, respond error Undefined Function bcsub()


Solution

  • According to PHP documentation, BCMath is not available by default with PHP7 on Linux servers.

    bcmath ist not installed automatically with php 7 on linux (ubuntu server) You have to use: sudo apt-get install php-bcmath

    Please install it using apt-get: sudo apt-get install php-bcmath

    Source: http://php.net/manual/en/bc.installation.php