Aki
Aki

Reputation: 85

PHP mktime() expects parameter

I'm not sure how to fix this one though, I've tried to search the same issue but I just got confused even more... any help please? Thanks in advance!

Error:

PHP Warning:  mktime() expects parameter 1 to be long, string given in /home/web/public_html/sample.php on line 85

PHP Script:

<?php
    $ArrDate=explode(' ',$datetime);
    $date=explode('/',$ArrDate[0]);
    $time=explode(':',$ArrDate[1]);
    // Check if new
    if(mktime($time[0],$time[1],$time[2],$date[1],$date[0],'20'.$date[2]) > $_COOKIE['newposts']) {
        $new='_new';
    }
?>

Line 85:

if(mktime($time[0],$time[1],$time[2],$date[1],$date[0],'20'.$date[2]) > $_COOKIE['newposts'])

Upvotes: 1

Views: 7031

Answers (1)

Evan Taylor
Evan Taylor

Reputation: 191

As mentioned by Novice in the comments use intval() to convert the parameters to integers.

intval($time[0])

Upvotes: 2

Related Questions