gish Posted February 7, 2009 Share Posted February 7, 2009 this function when called will elevate the month or decrease the month depending on the link you press. I know what the issue is date("m") + $_SESSION //works fine date("m") - $_SESSION //this works very very badly does anyone know how to fix it? =) function GetMonth(){ $Name = $_GET['m']; //this needs to be a session switch($Name) { case b: $_SESSION ['calendar']--; return mktime(0, 0, 0, date("m") - $_SESSION ['calendar'], date("d"), date("y")); break; case f: $_SESSION ['calendar']++; return mktime(0, 0, 0, date("m") + $_SESSION ['calendar'] , date("d"), date("y")); break; default: $_SESSION ['calendar']= 0; return mktime(0, 0, 0, date("m"), date("d"), date("y")); } } echo date("d/m/Y", GetMonth()); Link to comment https://forums.phpfreaks.com/topic/144178-solved-function-wont-work/ Share on other sites More sharing options...
landavia Posted February 7, 2009 Share Posted February 7, 2009 hmmm.. this hard request btw.. there an easy way.. but i think i should try your way <?php function GetMonth(){ $Name = $_GET['m']; //this needs to be a session switch($Name) { case b: $_SESSION ['calendar']--; $res= mktime(0, 0, 0, date("m") - $_SESSION ['calendar'], date("d"), date("y")); break; case f: $_SESSION ['calendar']++; $res=mktime(0, 0, 0, date("m") + $_SESSION ['calendar'] , date("d"), date("y")); break; default: $_SESSION ['calendar']= 0; $res= mktime(0, 0, 0, date("m"), date("d"), date("y")); } return $res; } echo date("d/m/Y", GetMonth()); ?> try this ^^ well.. Link to comment https://forums.phpfreaks.com/topic/144178-solved-function-wont-work/#findComment-756584 Share on other sites More sharing options...
gish Posted February 7, 2009 Author Share Posted February 7, 2009 the answer is this date("m") - $_SESSION ['calendar'] need to change it to this date("m") + $_SESSION ['calendar'] I had a double negative Link to comment https://forums.phpfreaks.com/topic/144178-solved-function-wont-work/#findComment-756585 Share on other sites More sharing options...
gish Posted February 7, 2009 Author Share Posted February 7, 2009 what is the easier way? =) Link to comment https://forums.phpfreaks.com/topic/144178-solved-function-wont-work/#findComment-756587 Share on other sites More sharing options...
landavia Posted February 7, 2009 Share Posted February 7, 2009 $_SESSION ['calendar'] => is month? <?php function GetMonth(){ $Name = $_GET['m']; //this needs to be a session $month1=$_SESSION ['calendar']; $month0=date("m"); switch($Name) { case b: $month1--; $res= mktime(0, 0, 0, $moth0-$month1); //$res= mktime(0, 0, 0, date("m") - $_SESSION ['calendar'], date("d"), date("y")); break; case f: $month1++; $res= mktime(0, 0, 0, $moth0+$month1); //$res=mktime(0, 0, 0, date("m") + $_SESSION ['calendar'] , date("d"), date("y")); break; default: $_SESSION ['calendar']= 0; $res= mktime();//0, 0, 0, date("m"), date("d"), date("y")); } return $res; } function getMonth1() { $Name = $_GET['m']; //this needs to be a session $month1=$_SESSION ['calendar']; $month0=date("m"); $month2=date('y')*12+date('m'); switch($Name) { case b: $month1--; $res= month2-month1; //$res= mktime(0, 0, 0, date("m") - $_SESSION ['calendar'], date("d"), date("y")); break; case f: $month1++; $res= month2+month1; //$res=mktime(0, 0, 0, date("m") + $_SESSION ['calendar'] , date("d"), date("y")); break; default: $_SESSION ['calendar']= 0; $res= month2;//0, 0, 0, date("m"), date("d"), date("y")); } $year1=floor($res / 12); $month3=($res%12) +1; return strtotime("$year1-$month3-".date(d)); } echo date("d/m/Y", GetMonth()); echo date("d/m/Y", getMonth1()); ?> omg.. there no easy way.. hick.. sry.. my bad Link to comment https://forums.phpfreaks.com/topic/144178-solved-function-wont-work/#findComment-756604 Share on other sites More sharing options...
gish Posted February 7, 2009 Author Share Posted February 7, 2009 yes but thanks =) Link to comment https://forums.phpfreaks.com/topic/144178-solved-function-wont-work/#findComment-756617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.