Jump to content


Photo

Need help with mktime() error in functions.php


  • Please log in to reply
1 reply to this topic

#1 Radzy

Radzy
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 17 April 2006 - 09:17 AM

Need help with a coding issue ...

Error reported:

Warning: mktime() expects parameter 6 to be long, string given in c:\mywebsite.com\rating-review\includes\functions.php on line 320

This is the following code I'm using:

function ifUpdated ($date)

{
global $def_updated;
$date_day = date ( "d" );
$date_month = date ( "m" );
$date_year = date ( "Y" );
list ( $on_year, $on_month, $on_day ) = split ( '[/.-]', $date );
$first_date = mktime ( 0,0,0,$on_month,$on_day,$on_year );
$second_date = mktime ( 0,0,0,$date_month,$date_day,$date_year );
if ( $second_date > $first_date )
{
$days = $second_date - $first_date;
}
else
{
$days = $first_date - $second_date;
}
$current_result = ( $days ) / ( 60 * 60 * 24 );
if ( $current_result <= 5 )
{
$updated_listing = "$def_updated";
}
else
{
$updated_listing = "";
}
return $updated_listing;
}


I'm pulling my hair out trying to figure what's wrong.. maybe something simple.. thnks for help .. in advance

#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 17 April 2006 - 11:30 AM

hmmm i tried your function out, as well as using strings, etc with mktime and couldnt reproduce your error.

- what version of php are you using?
- what is the level of error_reporting you have in your php.ini? you can find out with this if youre unsure:
echo ini_get('error_reporting');

apart from the warning, does the function still do its job?
i think there's a function to force a datatype onto a variable, but not sure - you can use this though to force a numeric string into an integer - just add zero:

$number = "12345";

$now_numeric = $number + 0;

edit: function for forcing integer is 'intval'
$number = "12345";

$now_numeric = intval($number);

hope that helps
Cheers
Mark
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users