Click to See Complete Forum and Search --> : Newbie - help with time function


moohuey
12-13-2005, 12:41 PM
I have an include in a php program that reads as follows:
<?php
function checkthis()
{
print("check this I'm here</br>");
}

function thismonth($stamp)
{
$time = getdate($stamp);
$newdate = $time['year']."-".$time['mon']."-01";
$newstamp = strtotime($newdate);
return $newstamp;
}

function lastmonth($stamp)
{
$time = getdate($stamp);
if ($time['mon'] == '01') { $ny = $time['year']-1; $newdate = $ny."-12-01"; }
else { $nm = $time['mon']-1; $newdate = $time['year']."-".$nm."-01"; }
$newstamp = strtotime($newdate);
return $newstamp;
}

function nextmonth($stamp)
{
$time = getdate($stamp);
if ($time['mon'] == '12') { $ny = $time['year']+1; $newdate = $ny."-01-01";}
else { $nm = $time['mon']+1; $newdate = $time['year']."-".$nm."-01"; }
$newstamp = strtotime($newdate);
return $newstamp;
}

?>


When I try to call this function, I end up with a blank screen
The function call reads
$this = thismonth(time());
It is immediately followed with print("$this"); to verify that it happened.
The intent, I think is to get the first of the current month.
I know the include is being read as I tried just running the function checkthis and that works.
Any ideas.
Thanks,
D

LiLcRaZyFuZzY
12-13-2005, 01:05 PM
$this is reserved, you can't assign a value to it
use something else, and if possible meaningful
e.g.:
$this_month or $thismonth or $current_month or $curr_month or $month etc..