I have date strings in "Y-m" format. Day is irrelevant here. Now I need to create another date from these date strings wheere day should be either 1st or the last day of the month. I have tried this code:
$curDate = DateTime::createFromFormat('Y-m', $datestring1);
$dt = $curDate->format('Y-m-d');
The problem here is that it creates dates with the current day of the months. How can I force it to do it for the 1st or last day?
Thanks