PHP – Get Days in Current Month

Calculating days in current month is pretty easy in PHP. Get the current month and year and use the inbuilt cal_days_in_month to get the number of days:

$mon = date("m");
$year = date("Y");
$days_in_mon = cal_days_in_month(CAL_GREGORIAN, $mon, $year);
Advertisements
Posted in PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s