Forum Moderators: coopster

Message Too Old, No Replies

mktime()

Behavior

         

henry0

2:27 pm on May 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I use the following:
It works fine
<<<<<
if(isset($_SESSION['dob_m']) && isset($_SESSION['dob_d']) && isset($_SESSION['dob_y']) )
{
$dob_parent=mktime(0,0,0,$_SESSION['dob_m'],$_SESSION['dob_d'],$_SESSION['dob_y']);
echo"parent $dob_parent<p>";
$dob=date('y/m/d',$dob_parent); echo"$dob";
}
else{$dob="";}
>>>>>

I am not very knowledgable about time
but if I use instead in mktime () the session value as for ex: $dob_y=$_SESSION['dob_y'];
(Which obviously is declared way above; plus I verified previously their value by echoing them in my "if")
<<<<<
if(isset($_SESSION['dob_m']) && isset($_SESSION['dob_d']) && isset($_SESSION['dob_y']) )
{
$dob_parent=mktime(0,0,0,$dob_m,$dob_d,$dob_y);
echo"parent $dob_parent<p>";
$dob=date('y/m/d',$dob_parent);echo"$dob";
}
else{$dob="";}
>>>>
Then it does not work and echoing
echo"parent $dob_parent<p>"; results in EMPTY

It drives me insane! I went to the manual but cannot find anything
what am I overlooking at?

joelgreen

2:45 pm on May 8, 2007 (gmt 0)

10+ Year Member



Really strange. I tried both and both are working ok on my pc.
Maybe following would help

$dob_y=(int)$_SESSION['dob_y'];

What are sample $_SESSION['dob_y'], $_SESSION['dob_m'], $_SESSION['dob_d'] values which are not working?

henry0

3:02 pm on May 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if I use the value NONE of those values will work!
when using the session it works

it is part of a long 1800 lines script
so I even tried by creating a small file as the one posted and do no get it working

but since it works on your machine

I am going to load it to my server test bed
instead of my local XAMP
thanks

henry0

3:40 pm on May 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



STRANGE
from my server test bed it does the same
more when the sessions values are called by using another var
for ex: $d=$_SESSION['dob_d']
and using $d in mktime() won't work!
then it totally default to year 69 that seems to be the default error

henry0

4:28 pm on May 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



well after changing of glasses 6 times
I found a values inversion in y d m :)

joelgreen

4:42 pm on May 8, 2007 (gmt 0)

10+ Year Member



Glad you resolved it :-) Here is what i tried and what was working ok.

$_SESSION['dob_m'] = '5';
$_SESSION['dob_d'] = '5';
$_SESSION['dob_y'] = '2007';

$dob_m = $_SESSION['dob_m'];
$dob_d = $_SESSION['dob_d'];
$dob_y = $_SESSION['dob_y'];

if(isset($_SESSION['dob_m']) && isset($_SESSION['dob_d']) && isset($_SESSION['dob_y']) )
{
$dob_parent=mktime(0,0,0,$dob_m,$dob_d,$dob_y);
echo"parent $dob_parent<p>";
$dob=date('y/m/d',$dob_parent);echo"$dob";
}
else{$dob="";}