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

Carbon::now after Carbon::setTestNow gives incorrect results #3006

Closed
vldmrnktn opened this issue Apr 24, 2024 · 1 comment · Fixed by #3014
Closed

Carbon::now after Carbon::setTestNow gives incorrect results #3006

vldmrnktn opened this issue Apr 24, 2024 · 1 comment · Fixed by #3014
Assignees
Labels
Milestone

Comments

@vldmrnktn
Copy link

Hello,

I encountered an issue with the following code:

$currentDate = Carbon::now()->setTimezone('America/Los_Angeles');
Carbon::setTestNow($currentDate);
echo Carbon::now()->format('Y-m-d H:i:s e');
echo Carbon::now('UTC')->format('Y-m-d H:i:s e');

Carbon version: 3.3.0

PHP version: 8.3.6

I expected to get identical result:

"2024-04-24 11:00:31 UTC"
"2024-04-24 11:00:31 UTC"

But I actually get:

"2024-04-24 04:00:31 UTC"
"2024-04-24 11:00:31 UTC"

Worked fine with php version: 8.2.18 Carbon version: 2.72.3

Thanks!

@kylekatarnls
Copy link
Collaborator

This will be fixed in 3.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants