busboy — 2011-01-09T09:30:01-05:00 — #1
When I view the variables that I currently have in my session, I see:
[loginCreated] => 2004-06-12
So far so good.
Then I have some code that pulls the variables out of the session that I need:
// Grab variables out of the session
$loginCreated = $_SESSION['loginCreated'];
$loginID = $_SESSION['loginID'];
In my php code, if I then do an echo $loginCreated I get:
Dec 31, 1969
I'm really not sure why this is happening, being that the date in the session is 2004-06-12. It gets even stranger. When I add the following code:
$timestamp2 = strtotime($loginCreated);
$loginCreated = date("M d, Y", $timestamp2);
The webpage results then show absolutely nothing. Can someone help me figure this out?
hostentic — 2011-01-09T09:52:58-05:00 — #2
Do you have code that runs in between your two times when you are pulling your variable our of session ?
Without seeing the full code it is going to be hard to determine what exactly is going on.
Also make sure that before you try to access session variables that session is turned on if it is not done automatically by the server
ernie1 — 2011-01-09T10:10:06-05:00 — #3
Do you get any error?
It could be that the session var is not defined, that's why you get the Unix Epoch (January 1 1970 00:00:00 GMT).
lorenw — 2011-01-09T10:13:08-05:00 — #4
After you start the session do this,
echo '<pre>'; print_r(); echo '</pre>';
That will tell you what you have in your session.
busboy — 2011-01-11T22:31:09-05:00 — #5
lorenw, your suggested code produced this error:
Warning: print_r() expects at least 1 parameter, 0 given in /home3/recordau/public_html/variables.php on line 5
busboy — 2011-01-11T22:35:55-05:00 — #6
Oh, lorenw, I figured the error out, because I didn't have $_session put inside the ( ). But like I said in my original post, the value in the session has always been correct. I'm just having a hard time figuring out why the date is formatted as:
Dec 31, 1969
cranial_bore — 2011-01-12T00:17:05-05:00 — #7
You probably haven't called session_start on that page. So $_SESSION['loginCreated'] will be empty. When you do strtotim() the result will be 0 (1 Jan 1970), which in your server's timezone is Dec 31, 1969.
Check the value of $timestamp2 before and after calling strtotime