<?php
$date = new \DateTime('first day of last month');
$date2 = new \DateTime('last month');
$date2->modify('first day of month');
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 (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF:4
Stack trace:
#0 /in/3ngKF(4): DateTime->modify('first day of mo...')
#1 {main}
thrown in /in/3ngKF on line 4
Process exited with code 255.
Warning: DateTime::modify(): Failed to parse time string (first day of month) at position 13 (m): The timezone could not be found in the database in /in/3ngKF on line 4
2015-09-01
2015-09-13