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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.