We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello,
I encountered an issue with the following code:
<?php require 'vendor/autoload.php'; use Carbon\Carbon; function showDate($date) { echo "Date:" . $date->format("Y-m-d") . ", floorMonth: " . $date->copy()->floorMonth()->format("Y-m-d") . PHP_EOL; } $date1 = Carbon::parse("2021-03-30"); $date2 = Carbon::parse("2021-03-31"); showDate($date1); showDate($date2);
Carbon version: 2.57.0 and 2.55.2
PHP version: 8.0.8 and 8.1.1
I expected to get:
Date:2021-03-30, floorMonth: 2021-03-01 Date:2021-03-31, floorMonth: 2021-03-01
But I actually get:
Date:2021-03-30, floorMonth: 2021-03-01 Date:2021-03-31, floorMonth: 2021-04-01
Thanks!
The text was updated successfully, but these errors were encountered:
Same issue with months that have 31 days:
<?php require 'vendor/autoload.php'; use Carbon\Carbon; function showDate($date) { echo "Date: " . $date->format("Y-m-d") . ", floorMonth: " . $date->copy()->floorMonth()->format("Y-m-d") . PHP_EOL; } for ($i = 1; $i <= 12; $i++) { showDate(Carbon::parse("2021-$i-01")->endOfMonth()); }
Output:
Date: 2021-01-31, floorMonth: 2021-02-01 Date: 2021-02-28, floorMonth: 2021-02-01 Date: 2021-03-31, floorMonth: 2021-04-01 Date: 2021-04-30, floorMonth: 2021-04-01 Date: 2021-05-31, floorMonth: 2021-06-01 Date: 2021-06-30, floorMonth: 2021-06-01 Date: 2021-07-31, floorMonth: 2021-08-01 Date: 2021-08-31, floorMonth: 2021-09-01 Date: 2021-09-30, floorMonth: 2021-09-01 Date: 2021-10-31, floorMonth: 2021-11-01 Date: 2021-11-30, floorMonth: 2021-11-01 Date: 2021-12-31, floorMonth: 2022-01-01
Sorry, something went wrong.
Take minimum value for rounding
3ff0d04
Fix briannesbitt#2581
This will be fixed in the next release, it can be tested using composer require "nesbot/carbon:dev-master as 2.58.0"
composer require "nesbot/carbon:dev-master as 2.58.0"
Thanks 🙏
kylekatarnls
Successfully merging a pull request may close this issue.
Hello,
I encountered an issue with the following code:
Carbon version: 2.57.0 and 2.55.2
PHP version: 8.0.8 and 8.1.1
I expected to get:
But I actually get:
Thanks!
The text was updated successfully, but these errors were encountered: