I need to set a DateTime object on a specific day of the current month. I obviously can do this by getting the current month and creating a new DateTime or checking the current day and creating a DateInterval object to change the DateTime, but I just want to give the text arguments of DateTime :: modify.
I am looking for something like:
$datetime->modify('10th day this month');
but it gives me an error for example
PHP Warning: DateTime :: modify (): Failed to parse the time string (10th day of this month) at position 0 (1): Unexpected character in php shell code on line 1
and I don't seem to be able to find the right sentence construct to make PHP look pretty.
source
share