php - issue with date() function. Need it to calculate from the first of the month -
ok, have code.
else if($_post['sdate'] == 'this month') { $startdate = date("m/d/y"); $newdate = datetime::createfromformat("m/d/y",$startdate); $dpicker = $newdate->format("y-m-d"); echo $dpicker; $enddates = date("m/d/y"); $newedate = datetime::createfromformat("m/d/y",$enddates); $newedate->modify('-20 day'); $edpicker = $newedate->format("y-m-d"); echo $edpicker; $thdate = $dpicker; $thdates = $edpicker; $sql = "select * orders loggedtime between :times , :time"; $q=$con->prepare($sql); $q->bindparam(":time", $thdate); $q->bindparam(":times", $thdates); $q->execute(); while($data=$q->fetch(pdo::fetch_assoc)) { echo $data['customer']; } }
so right $edpicker
set go 20 days today... calculate today 7th, go 7 days.. want variable go first of month. if today 18th.. go 18 days.
whats best way this?
$firstdayofmonth = new \datetime('first day of month');
Comments
Post a Comment