syaifulhusein
syaifulhusein

Reputation: 279

How to Take the number of days from specific month in Codeigniter?

I want count days from specific month. I see from documentation Codeigniter, use this function.

echo days_in_month(06, 2005);

On that function, we must add int month and year. I want take number of days from month and year be dynamic without we add int month and year. Ex : i want take number of days from this month and this year.

Upvotes: 2

Views: 3358

Answers (2)

ImBhavin95
ImBhavin95

Reputation: 1527

You can use below function

<?php
    $d = cal_days_in_month(CAL_GREGORIAN,6,2005);
    echo $d.' Days';
?>

Resource from https://www.w3schools.com/php/func_cal_cal_days_in_month.asp

Upvotes: 0

dhruv jadia
dhruv jadia

Reputation: 1680

$pass_date = strtotime('2016-06-29');
$total_days = cal_days_in_month(CAL_GREGORIAN, date('m', $pass_date), date('Y', $pass_date));
echo $total_days;

Upvotes: 2

Related Questions