Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

masonfox's avatar

Command Using Carbon for Incrementing Time

I have a command that is used to bill customers whose bill date is today, which is then incremented by a month. I know this sounds weird and you're going to say, use Stripe subscription. Well I am using Stripe for processing payments, but my application billing logic is too complicated for subscriptions alone.

So I am billing each user whose charge_date is today. If it is today I charge them. If the charge is successful, I increment the charge_date by a month, except I use Carbon and use Carbon::today() instead of incrementing the existing charge_date. I'm doing that so the next charge will be a full month after their last successful charge. Maybe I should do that, maybe not.

I am using a trait to do this so I can call it from a controller and the command. The date change works 100% every time in the controller, but it doesn't increment correctly when I run the command. The charges are successful, but the command does not increment the month correctly.

I also don't get an error.

Any thoughts on this?

0 likes
1 reply
masonfox's avatar

Looks like I may have forgotten to add:

use Carbon\Carbon;

At the top of my command. I will post here if anything changes.

Please or to participate in this conversation.