oh my fucking god php is such a fucking trainwreck
in particular its date handling leaves QUITE A LOT to be desired
I mean there's also the big security hoobajoob but that's not the bit that's frustrating me at the moment
Discussion
oh my fucking god php is such a fucking trainwreck
in particular its date handling leaves QUITE A LOT to be desired
I mean there's also the big security hoobajoob but that's not the bit that's frustrating me at the moment
@fluffy Something like:
```php
$now = new DateTime();
$now->setTimezone(new DateTimeZone("America/Los_Angeles"));
echo $now->format("w");
```
@cthos I don't want to change it at the ini level, and yeah the datetime approach is what everything points me to but it's so annoying to have to do that to replace a one-line hack on a piece of code I wrote for a quick and dirty thing 25 years ago
@cthos anyway I ended up doing this anyway, just because why not
it's still stupid how difficult it was to find all the various fiddly little bits on how to do it though (thanks for writing the only concise example code I've come across btw)
out of desperation I asked Gemini and it gave answers which look correct but involve writing a LOT more code than should be necessary for this
okay to be fair the easy way I'd do this in Python would involve importing arrow but it'd still result in a nice simple oneliner
but gosh, so much of the php standard library is just a thin wrapper around the C standard library, with a little bit of jank-ass object conversion
searching stackoverflow only finds things that are either wildly incorrect or answering a completely different question (often a different question than what's being asked too)
all I'm trying to do is get the numeric day of the week in the local timezone
date("W") goes based on GMT or needs a UNIX timestamp in localtime
localtime() returns a structured datetime array and I don't see any way to convert that into a UNIX timestamp
I don't see any way to do date formatting based on a datetime array
what a miserable fucking language