for verification as a bug, can someone test this with his php:
$timeZone = new DateTimeZone('Europe/Berlin');
$startDate = new DateTime('first day this month 00:00:00', $timeZone);
echo $startDate->format('d.m.Y');
Result:
02.02.2013
I’ve tested it with php 5.2 and PHP 5.3, with same result….
As a “resolution”, what’s the best alternate way to do this?
$timeZone = new DateTimeZone('Europe/Berlin');
$startDateAlt = new DateTime('now', $timeZone);
$startDateAlt->setTimestamp(mktime(0, 0, 0, date("m") , 1, date("Y")));
You omitted the
of, so it parses it as something else:returns
If for some reason this doesn’t work (old php version it seems from your comment), you can try this? Bit of a hack maybe…