Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: CarbonImmutable::createFromTimeString('first day of this year 00:00:00') returning February 1st instead of January 1st #2950

Closed
niravpateljoin opened this issue Feb 26, 2024 · 2 comments
Labels
php bug Related to a bug of PHP

Comments

@niravpateljoin
Copy link

Hello,

I encountered an issue with the following code:

echo CarbonImmutable::createFromTimeString('first day of this year 00:00:00');

Carbon version: 3.0.2

PHP version: ** 8.2.15**

I expected to get:

2024-01-01 00:00:00.0 UTC (+00:00)

But I actually get:

2024-02-01 00:00:00.0 UTC (+00:00)

Thanks!

@niravpateljoin niravpateljoin changed the title Carbon 3, Facing Wrong output using following code Bug: CarbonImmutable::createFromTimeString('first day of this year 00:00:00') returning February 1st instead of January 1st Feb 26, 2024
@kylekatarnls kylekatarnls added the php bug Related to a bug of PHP label Feb 27, 2024
@kylekatarnls
Copy link
Collaborator

kylekatarnls commented Feb 27, 2024

Hello,

This is not on our side, the same happens with pure PHP:

echo (new DateTimeImmutable('first day of this year 00:00:00'))->format('Y-m-d H:i:s e');

https://3v4l.org/Ro64L

I don't know if this syntax is supported.

This should be reported on https://github.com/php/php-src instead.

@kylekatarnls
Copy link
Collaborator

However, it's possible to achieve it using:

echo CarbonImmutable::now()->startOfYear();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
php bug Related to a bug of PHP
Projects
None yet
Development

No branches or pull requests

2 participants