Open asmecher opened 1 month ago
Patterns that are good (in my opinion):
Patterns that are bad:
strtotime
and manual math on date/datetime contentI'm all for using the classes wherever possible, it's just needed to have some attention when dealing with different time zones.
I mean, a user inputting 2024-07-31T00:00:00+00:00
and another 2024-07-31T00:00:00+12:00
, shouldn't lead to 2024-07-31 00:00:00
in the database.
Another thing to think, not related with this task is allowing the user to setup its time zone or to make it clear which time zone is being used on the system.
As MySQL doesn't support storing dates with time zones, we need to ensure they are converted to the system time zone when storing it.
Describe the bug Historically we've used a mix of ints (UNIX epoch timestamps) and strings (parsable date representations, usually converted with
strtotime
) for date/datetime data in PHP.Now that we're adopting more Laravel / Eloquent, and now that PHP has better support for
DateTime
/DateTimeImmutable
types, and now that we're adding typehinting, it's time to pick a lane and use it consistently.(This will require some investigation and thought, both in what specific choices we make and in how it's rolled out. Ideas welcome.)