Skip to content

firstDayOfQuarter and firstDayOfPreviousQuarter returns wrong day sometimes #3996

@oliworx

Description

@oliworx
  • Laravel Version: 8.83
  • Nova Version: 3.30
  • PHP Version: 8.0.17
  • Database Driver & Version:
  • Operating System and Version: Linux 5.4.0
  • Browser type and version:
  • Reproduction Repository:

Description:

The calculated date is correct for timezones in the eastern hemisphere (like Europe/Berlin), but wrong by one day for UTC or timezones in the western hemisphere (like America/Chicago).

The correct day should always be the first day of a month.

Detailed steps to reproduce the issue on a fresh Nova installation:

open tinker in terminal

>>> Illuminate\Support\Carbon::firstDayOfQuarter('Europe/Berlin');
=> Illuminate\Support\Carbon @1648764000 {#3922
     date: 2022-04-01 00:00:00.0 Europe/Berlin (+02:00),
   }
>>> Illuminate\Support\Carbon::firstDayOfQuarter();
=> Illuminate\Support\Carbon @1648684800 {#3918
     date: 2022-03-31 00:00:00.0 UTC (+00:00),
   }
>>> Illuminate\Support\Carbon::firstDayOfQuarter('America/Chicago');
=> Illuminate\Support\Carbon @1648702800 {#3919
     date: 2022-03-31 00:00:00.0 America/Chicago (-05:00),
   }
>>> Illuminate\Support\Carbon::firstDayOfPreviousQuarter('America/Chicago');
=> Illuminate\Support\Carbon @1640930400 {#3930
     date: 2021-12-31 00:00:00.0 America/Chicago (-06:00),
   }
>>> Illuminate\Support\Carbon::firstDayOfPreviousQuarter('Europe/Berlin');
=> Illuminate\Support\Carbon @1640991600 {#3918
     date: 2022-01-01 00:00:00.0 Europe/Berlin (+01:00),
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingIssues that are pending triage

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions