Carbon: 馃悰 preg_match(): Unknown modifier '['

Created on 4 Sep 2020  路  2Comments  路  Source: briannesbitt/Carbon


Hello,

I encountered an issue with the following code:

Carbon::hasFormat('2020-09-01 12:00:00Europe/Moscow','Y-m-d H:i:se');

Carbon version: 2.39.0

PHP version: 7.4.3

I expected to get:

true

But I actually get:

   ErrorException 

  preg_match(): Unknown modifier '['

  at vendor/nesbot/carbon/src/Carbon/Traits/Comparison.php:891
    887| 
    888|                 $regex .= strtr($quotedFormat[$i], static::$regexFormats);
    889|             }
    890| 
  > 891|             return (bool) preg_match('/^'.str_replace('/', '\\/', $regex).'$/', $date);
    892|         } catch (InvalidArgumentException $e) {
    893|         }
    894| 
    895|         return false;

      +1 vendor frames 
  2   app/Console/Commands/Dev/RunTestCommand.php:99
      Carbon\Carbon::hasFormat()

      +14 vendor frames 
  17  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Thanks!

bug

Most helpful comment

Fixed in 2.39.1

All 2 comments

Thank you for the report. I will fix it.

Fixed in 2.39.1

Was this page helpful?
0 / 5 - 0 ratings