Tuesday, August 13, 2013

how to get no of days in the current month(count)?

$da = date('d'); // gets the current day of the month
$mth = date('m');    // gets the current month
$yr = date('Y');   // gets the current year
$daysinmonth = cal_days_in_month(CAL_GREGORIAN,$mth,$yr);
echo $daysinmonth;   // this will echo the total no of days in the current month

now you might also want to use the no of days left in the current month from the current day, here's how that's done:-

$baldays = $daysinmonth - $da;
echo $baldays;    // this would echo out the no of days remaining for the current month to end

No comments:

Post a Comment