briannesbitt / Carbon

A simple PHP API extension for DateTime.
https://carbon.nesbot.com/
MIT License
16.59k stars 1.28k forks source link

Check month issue #3032

Closed narek8888 closed 5 months ago

narek8888 commented 5 months ago

Hello,

I encountered an issue with the following code:

        $reportDate = now()->subMonth()->lastOfMonth();
        dd($reportDate->is('May'), $reportDate->is('April'));

Carbon version: * 2.67.0

PHP version: 8.1.2

I expected to get:

true, false

But I actually get:

true, true

Thanks!

kylekatarnls commented 5 months ago

Hello,

I confirm this is a bug.

I suggest this work-around in the meantime:

dd(
    $reportDate->copy()->startOfMonth()->is('May'),
    $reportDate->copy()->startOfMonth()->is('April')
);

Important note: I have to evaluate if I can fix it and make it go either to 2.72.4 patch or 3.5.0, but the version 2.67.x will no longer receive fixes.

Thanks for the report. 🙏