Standard letter-based representations of date parts are great, except the fact they're not so intuitive. The much more convenient way is to identify basic abstractions and a number of specific implementations. Besides, with this approach, you can benefir from autocompletion.
Since we're talking about datetimes here, it seems plausible that the basic abstraction is ISO8601DateTime
. One of the specific implementations is current datetime, the one you need when a makes a request to your backend, hence Now()
class. Second one which is of some use for you is a datetime adjusted to some timezone. Not surprisingly, it's called AdjustedAccordingToTimeZone
. And finally, you need a day of the week in a passed datetime's timezone: there is a LocalDayOfWeek
class for that. So the code looks like the following:
(new LocalDayOfWeek(
new AdjustedAccordingToTimeZone(
new Now(),
new TimeZoneFromString($_POST['timezone'])
)
))
->value();
For more about this approach, take a look here.