Link to home
Start Free TrialLog in
Avatar of Larry Vollmer
Larry Vollmer

asked on

php time question

I have the following variable:
$expires_on = '2012-01-02 00:00:00';

the variable is set to expire on midnight, Jan 2, 2012.

Pacific time is 3 hours behind my time zone, does this mean that I am setting the time to expire at 9:00PM in the pacific timezone?
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

If the server is in Eastern timezone then Yes.


Cd&
Avatar of Larry Vollmer
Larry Vollmer

ASKER

is there a way to set it so that the variable sets to midnight in the users timezone?
Depends on context.  You would have to detect the users location (Which can be block or spoofed).  The local user time would be used on the client side, so if you just want there local times you could have that sent from the client in a form field (of course that could also be wrong).  If you have it on your database and you know the timezone of the client then you can adjust on the server.  It all really comes down to what you are trying to do with the time.


Cd&
basically if the present time is greater then or equal to the default time stored in the $expires_on variable, the user is redirected to a page that says "sorry, this page is no longer available"
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Cd& -- right, but only if the client puts the 'date' into the request.  Try running this little script.  You would expect to see the GET, POST, COOKIE vars.

In the article, "Practical Application #8" shows how I have dealt with this issue in the past.

And speaking of "practical" you might ask, "What would happen if I left the page up a little too long?"  If the answer to that is not something catastrophic, it might be easy to just leave the page up a little too long.
<?php // RAY_bounce_request.php
error_reporting(E_ALL);
echo "<pre>" . PHP_EOL;
echo "HERE IS THE REQUEST ARRAY:" . PHP_EOL;
var_dump($_REQUEST);

Open in new window

@lvollmer: Based on the accepted solution, I think that you might want to install the "bounce_request" script on your server and run it.  Don't leave it online; it is a security exposure.  But just run it once to see if you get the 'date' field that you think you will get.

In case you're not completely satisfied with the output of the bounce_request script, read the article, and in particular read Practical Application #8.

Best to all, ~Ray
thanks to all