Is there a better way of returning the date for the first day of a specific month/year, than the following?
$month = date('m');
$year = date('Y');
$from = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
This is not exactly computationally elegant, but I like it because it's so readable:
strtotime("first day of this month");
Why so complicated?
date("Y-m-01")
This will work just fine ;)
(Don't worry, I kicked myself hard for wasting an hour messing with strtotime
before realising I could do this!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With