Jump to content

Warning: mktime() expects parameter 5 to be long, string given


sitesme

Recommended Posts

Hi,

 

I'm getting this error:

 

Warning: mktime() expects parameter 5 to be long, string given in /home/user/public_html/include/functions.php on line 58

 

The code is:

		if($Date_Format == 1)		#For dd-mm-yyyy
	{
		$Date_Output	=	date("d-m-Y",mktime(0,0,0,$Month,$Day,$Year));
	}
	elseif($Date_Format == 2)		#For dd/mm/yyyy
	{
		$Date_Output	=	date("d/m/Y",mktime(0,0,0,$Month,$Day,$Year));
	}
	elseif($Date_Format == 3)		#For mm-dd-yyyy
	{
		$Date_Output	=	date("m-d-Y",mktime(0,0,0,$Month,$Day,$Year));
	}
	elseif($Date_Format == 4)		#For mm/dd/yyyy
	{
		$Date_Output	=	date("m/d/Y",mktime(0,0,0,$Month,$Day,$Year));
	}
	elseif($Date_Format == 5)		#For Mon Day YYYY
	{
		$Date_Output	=	date("M D Y",mktime(0,0,0,$Month,$Day,$Year));
	}
	elseif($Date_Format == 6)		#For Month Day YYYY
	{
		$Date_Output	=	date("F D Y",mktime(0,0,0,$Month,$Day,$Year));
	}

	elseif($Date_Format == 7)		#For Date"nd" Month YYYY
	{
		$Date_Output	=	date("d\\t\h F Y",mktime(0,0,0,$Month,$Day,$Year));
	}
		elseif($Date_Format == 		#For Month Day YYYY
	{
		$Date_Output	=	date("F d Y",mktime(0,0,0,$Month,$Day,$Year));
	}
		elseif($Date_Format == 9)		#For Month Day YYYY
	{
		$Date_Output	=	date("d/m/Y H:i",mktime($DateDispsplittimehr,$DateDispsplittimemin,0,$Month,$Day,$Year)); // Line 58
	}

	return $Date_Output;
}
else
{
	return NULL;

 

Line 58 says

		$Date_Output	=	date("d/m/Y H:i",mktime($DateDispsplittimehr,$DateDispsplittimemin,0,$Month,$Day,$Year));

 

I really appreciate any help on this.

 

Hum... I'm not really a programmer with that knowledge I'm afraid...

 

What I know is that it was working fine on another server so it might be a configuration in PHP or MySQL

 

Any help is appreciated.

 

What does it show if you do this before the if condition?

 

echo $Day;

Hi,

 

It shows this:

Friday

Warning: mktime() expects parameter 5 to be long, string given in /home/user/public_html/include/functions.php on line 58

Wednesday

Warning: mktime() expects parameter 5 to be long, string given in /home/user/public_html/include/functions.php on line 58

Hi,

 

It shows this:

Friday

Warning: mktime() expects parameter 5 to be long, string given in /home/user/public_html/include/functions.php on line 58

Wednesday

Warning: mktime() expects parameter 5 to be long, string given in /home/user/public_html/include/functions.php on line 58

 

I don't see how it could've worked on another server, maybe error_reporting was turned off so you just didn't get warnings.  The day is supposed to be the day number of the month, like today is 18.

In a way that is kind of funny, because php had this brilliant idea that hiding errors was okay.

 

Your code always contained that error because mktime() NEVER accepted week day names, but the actual error message was being hidden or was filling up your error log on the server. Php still must handle each error in your code, even if the error_reporting or display_errors settings are off. All those settings do is prevent the reporting and display of an error, but php still goes through the error response code every time your script produces an error.

 

So, the question becomes, why is your script putting week day names in as the day of the month and what does your script expect as a result?

I understand the matter, and thanks to all for letting me understand the problem better.

 

Obviously I would like to fix the code, how can I do this?

Is it in the code or in the database? I'm not a programmer, I'm simply trying to fix the code with my low knowledge.

 

Any help is appreciated.

 

Thanks.

I understand the matter, and thanks to all for letting me understand the problem better.

 

Obviously I would like to fix the code, how can I do this?

Is it in the code or in the database? I'm not a programmer, I'm simply trying to fix the code with my low knowledge.

 

Any help is appreciated.

 

Thanks.

 

It depends upon where $Month,$Day,$Year are coming from and what date you expect to get.  If you want an exact date then you have to provide the day of the month (e.g. 18) from somewhere.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.