Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cal_days_in_month () function is not working

Tags:

php

This cal_days_in_month() is not working in PHP version 5.2.11

$days_in_month = cal_days_in_month(0,$month,$year);
like image 719
Raj Kumar Avatar asked Feb 11 '12 14:02

Raj Kumar


2 Answers

Try

date('t', mktime(0, 0, 0, $month, 1, $year)); 

And I found in internet that it require PHP to compile with calender support.

"recompile php with the "--enable-calendar" option."

like image 129
Prasad Rajapaksha Avatar answered Oct 19 '22 16:10

Prasad Rajapaksha


Having the same problem in a docker container (based on image php:7.4-apache-buster) adding following line in Dockerfile solved the problem:

RUN docker-php-ext-install calendar

like image 27
qwertz Avatar answered Oct 19 '22 16:10

qwertz