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?
lvollmerAsked:
Who is Participating?
 
COBOLdinosaurCommented:
When the request comes in you can just check the request variables:

$_REQUEST['date'] will return the date in the format: Tue, 15 Nov 1994 08:12:31 GMT

So you can just parse out the user's local time.


Cd&
0
 
COBOLdinosaurCommented:
If the server is in Eastern timezone then Yes.


Cd&
0
 
lvollmerAuthor Commented:
is there a way to set it so that the variable sets to midnight in the users timezone?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
COBOLdinosaurCommented:
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&
0
 
lvollmerAuthor Commented:
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"
0
 
Ray PaseurCommented:
Use date_default_timezone_set() to correct for time zones.  This article tells you more about how to handle this issue.  Please read it over and post back if you still have any questions.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
0
 
Ray PaseurCommented:
@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

0
 
Ray PaseurCommented:
@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
0
 
lvollmerAuthor Commented:
thanks to all
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.