Skip to content

Refactor time, date and strtotime function usage to Carbon #8695

@OA

Description

@OA

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions