473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

cal_days_in_month() not present

exoskeleton
104 100+
hi dear experts... does cal_days_in_month() function is not present in php 4.4.4? i test the function with the code function_exist and return NOT PRESENT.

what is the other walk-around or alternative way to function as cal_days_in_month()?

please help...Thank you
Apr 21 '07 #1
4 1953
exoskeleton
104 100+
anyone please help...
Apr 24 '07 #2
The bodge version is to use a switch statement:

switch($month)
{
case 01: $days=31; break;
case 03: $days=31; break;
case 04: $days=30: break;
etc etc.....
}

Obviously in the case of February you need to work out if it's a leap year or not. I'd use date('L', $timestamp);
Apr 24 '07 #3
exoskeleton
104 100+
The bodge version is to use a switch statement:

switch($month)
{
case 01: $days=31; break;
case 03: $days=31; break;
case 04: $days=30: break;
etc etc.....
}

Obviously in the case of February you need to work out if it's a leap year or not. I'd use date('L', $timestamp);
I'll try your code sir...thank you
Apr 25 '07 #4
if your user inputs the month and year, use this:

$lastday = date("d", mktime(0, 0, 0, $month +1, 0, $year));
echo $lastday;

adding 1 to the month and setting the day at 0 forces date() to subtract a day, giving you the last day of the given month.

if you want the number of days in the current month modify it like this:

$month = date("n");
$year = date("Y");
$lastday = date("d", mktime(0, 0, 0, $month +1, 0, $year));
echo $lastday;

That's the easiest way I know of.
Apr 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ralf Wahner | last post by:
Dear Masters of XML As I'm new to XML Schema I dare to ask a possibly recurring question: Given an element <elem> with two attributes @a and @b. The attributes are bound by the condition, that...
3
by: The Dana's | last post by:
I need to create a static HTML file that runs only on the local client PC. On the page (say PageA.htm), I would like for a hypelink to another page (Page B) to appear ONLY if the target file the...
1
by: ning | last post by:
It's easy to present "One - Many" relationship in XML, but how to present "Many - Many" relationship in XML?
7
by: AA Arens | last post by:
I have a field "Notes" and I would like to have a button in the vicinity doing the following: It goes to the end of the present text, already filled in the Note-field, performs a and put in the...
2
by: Dafna m | last post by:
Hi, 1. How can I present diffrent image type (jpg, bmp, bpm..) 2. How can I present video file as a picture Can I fo it by a built in function (in C#)? *** Sent via Developersdex...
2
by: Brent Burkart | last post by:
Below is the error I am receiving. I have checked SQL Profiler and it is receiving the correct query which runs fine in Query Analyzer. Any ideas? Server Error in '/lockinsheet' Application....
0
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format....
1
by: Andrew | last post by:
Hi there, I'm trying to find out what is causing this error: <faultstring>Procedure 'foo' not present</faultstring> I've got a class 'bar' with a public function 'foo'. I create a...
0
by: =?Utf-8?B?R2VuaXVzIExvZ2ljcw==?= | last post by:
I am a newbie to WSE and I am using WSE 3.0. Scenario is that I have created server side certificate using makecert tool and added it to client side as present in the batch file that comes with the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.