Is there a better way to return the date on the first day of a particular month / year than the following?
$month = date('m'); $year = date('Y'); $from = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
This seems like the right way to do this with me. You might want to make it a function.
It's not quite elegant, but I like it because it is so readable:
strtotime("first day of this month");
?
date("Y-m-01")
;)
( , , , strtotime, , !)
strtotime
date("Y-m-01") ; , . :
if(!isset($FromDate)) $FromDate=date('Y-m-01'); //date with current month first day if(!isset($ToDate)) $ToDate=date('Y-m-d'); /////current date
, .