Jump to content

Help with mktime()


HughbertD

Recommended Posts

Hi,

I am getting the following error when clicking "next month" on my calendar,

 

Warning: mktime() expects parameter 4 to be long, string given in calendar.php

 

The line it references shows the mktime as -

 

        $tdate = getdate(mktime(0,0,0,$mon,$tday,$year));

 

I'm not sure why this is wrong, I checked on W3schools and i think the syntax are correct, I was reluctant to post all the code as its quite large, but can if the problem is not within the snippet I posted,

 

Thanks for any help

 

Regards

Hugh

Link to comment
Share on other sites

Are you sure your variables within mktime are valid?

 

 

Hi,

 

I am not sure whether the variables ARE valid or not, here is the code above the mktime that defines the variables

 

<?php
echo "mon = $mon<br>tday = $tday<br>year = $year<br>"
die();
$tdate = getdate(mktime(0,0,0,$mon,$tday,$year));

 

PhREEEk

 

Hi,

<?php




$ev_dat = array();
for ($i=0;$i<32;$i++) {
    $ev_dat[$i]=0;
}

$now = date("Y-m-d", time());
list($ty, $tm, $td) = explode('-',$now); // ty=thisyear, etc. used for highlighting 'today'

include("cal_parms.php"); // assorted configuration variables
include($dat_names); // retrieved from cal_parms.php as a 'language' file

if (!isset($_GET['m'])) { 
    $m = date("m",mktime()); 
} else {
    $m = $_GET['m'];
}
if (!isset($_GET['y'])) {
    $y = date("Y",mktime());
} else {
    $y = $_GET['y'];
}

/*== get what weekday the first is on ==*/ 
$tmpd = getdate(mktime(0,0,0,$m,1,$y)); 
$month = $tmpd["month"]; 
$firstwday= $tmpd["wday"]; 
if ($firstDayIsMonday == 1) {
if ($firstwday == 0) {
	$firstwday = 6;
} else {
	$firstwday--;
}
}
$lastday = mk_getLastDayofMonth($m,$y); 

/*== get the last day of the month ==*/ 
function mk_getLastDayofMonth($mon,$year) 
{
    for ($tday=28; $tday <= 31; $tday++) 
    {
        $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); 
        if ($tdate["mon"] != $mon) 
        { 
            break;
        }
    }
    $tday--; 
    return $tday; 
}

Link to comment
Share on other sites

Hi again,

 

Sorry, I've realised what you were saying, I used the echo to show the variables, clicked next and got:

 

EDIT: I wasn't clicking next, these are the variables when I click next, these are invalid right?  ;)

mon = 12) ? 1 : $m 1 ?>

tday = 28

year = 12) ? $y 1 : $y ?>

Link to comment
Share on other sites

Thanks Kishan,

 

Thats removed the errors!

 

One other thing I am having trouble with is when clicking "next" month, it can't seem to calculate the what the next month is!

 

Usually for "show events" I have,

 

http://localhost/joStark/calendar/show-month.php?mon=12&yr=2007

 

As my URL, I understand that much, but when I click next month it turns to gibberish, I would have thought that next month would be calculated by adding one to the month value, but the code says:

 

<th width="20" style="<? echo $hcell; ?>"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m+1)>12) ? 1 : $m+1 ?>&y=<?=(($m+1)>12) ? $y+1 : $y ?>"><img src='calendar/images/next.gif' height='18' width='18' border='0' alt='' /></a></th> 

 

This seems really over the top, or am I missing something important?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.