rector icon indicating copy to clipboard operation
rector copied to clipboard

Refactor time, date and strtotime function usage to Carbon

Open OA opened this issue 1 year ago • 0 comments

Feature Request

I'd like to see combinations of date and strtotime like the one in the first diff converted to use Carbon. Always converting strtotime($invoice->getDate()) to something like Carbon::parse($invoice->getDate())->timestamp seems like a lot of overhead but this might be an idea too. The same applies to calculations using unix timestamps as can be seen in the second diff. Please let me know if this makes sense to you.

Diff

-date('d.m.Y', strtotime($invoice->getDate()))
+Carbon::parse($invoice->getDate())->format('d.m.Y')
-time() - (60 * 60 * 24 * 14)
+Carbon::now()->subWeek()

OA avatar Jun 26 '24 16:06 OA