Hi,
I can't seem to determine the cause of this error:

Warning: mktime() expects parameter 6 to be long, string given in functions.php on line 291

Here is function causing this error:

/* ************************************************************************* */

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;
}

/* ************************************************************************* */

line 291 is: $first_date = mktime ( 0,0,0,$on_month,$on_day,$on_year );

Any help is greatly appreciated 🙂

    what's the $date you feed in to the function look like?

      added the following line to this function:

      echo ($date);

      Returns the following:

      2009-09-30

        testing it here it works fine as long as the date is in that format.

          Hi, sorry it still doesn't work on my end?

          I'm am newbie and trying to debug this..

          what does this line do:

          list ( $on_year, $on_month, $on_day ) = split ( '[/.-]', $date );

          The variable: $on_year

          seems to be causing this error..

            mktime() expects parameter 6 to be long, string given

            could it be something to do with the term "string" shouldn't this variable be an interger?

              function is fine, as long as thats the date, sure its the date? and thats the right function?

                Why not echo out the variables and see what data is being passed to the function?

                  I got it working. The function is fine.. Yes..
                  Server was the problem - works perfectly now - thank-you for the help! 🙂

                    11 years later

                    When asking questions, you should be aware that it is not just about you. That is the purpose of a forum - so that others who have the same problem may learn also. "Server was the problem - works perfectly now" tells us nothing about what you did to solve the problem.

                    RationalRabbit Also, replying to an 11-year-old thread is highly unlikely to be read by the person you're replying to.

                      Write a Reply...