<?php
$date = new \DateTime('first day of last month');
$date2 = new \DateTime('last month');
$date2->modify('set first day');
echo $date->format('Y-m-d') . "\n";
echo $date2->format('Y-m-d') . "\n";
Fatal error: Uncaught DateMalformedStringException: DateTime::modify(): Failed to parse time string (set first day) at position 0 (s): The timezone could not be found in the database in /in/ZifYg:4
Stack trace:
#0 /in/ZifYg(4): DateTime->modify('set first day')
#1 {main}
thrown in /in/ZifYg on line 4
Process exited with code 255.
Warning: DateTime::modify(): Failed to parse time string (set first day) at position 0 (s): The timezone could not be found in the database in /in/ZifYg on line 4
2015-09-01
2015-09-13