[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.0

How to return the correct user time if the server is somewhere else...

Asked by pr0fess0r in PHP and Databases

Tags: epoch_seconds, gettimezoneoffset, offset

Hi Guys - I'm gonna post this in the Javascript forum too... here goes.
I have a MySQL/PHP database being stored on a US PHP server but I am in New Zealand.
When a user logs in, I want to store the difference between their time and server time in minutes in a PHP session variable. To work around the potential Daylight Savings issues, and incorrect Time Zone settings, I assume the user's PC is set to their correct time.
I assumed that the Date() function in javascript returned the date/time on the user's machine (Javascript is clientside, right?)
So on the login form I have:
...
<input type=hidden name=clienttime>
...
<SCRIPT LANGUAGE="JavaScript"><!--
var now = new Date();
var epoch_seconds=Math.round(now.getTime()/1000);
document.form.clienttime.value=epoch_seconds;
//--></SCRIPT>

and in my php I set a session variable to the difference between time() - the server time in seconds since epoch - and my clienttime value.
...
$_SESSION["SESSION_TIMEOFFSET"] = $clienttime-time();
...
I expected this to work out to xxxx seconds. So, any time the user added something to the the database, it would go in as the server time, but any time the user views anything from the database, the time offset is applied so they see the data in their time.
But, my code doesnt work! Date() seems to be returning the server time!
Can anyone suggest a solution? I'd prefer not to use javascript's getTimeZoneOffset if i dont have to, because this can be inaccurate.
Is my thinking flawed?
NB Please dont refer me to this article - http://www.i-source101.com/read.php?articleid=5 I have seen copies of it everywhere and it's just confusing :)

many thanks in advance
[+][-]05/20/03 02:32 PM, ID: 8553787Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: PHP and Databases
Tags: epoch_seconds, gettimezoneoffset, offset
Sign Up Now!
Solution Provided By: Big_Red_Dog
Participating Experts: 2
Solution Grade: C
 
[+][-]05/19/03 05:11 PM, ID: 8547668Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/19/03 05:15 PM, ID: 8547674Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/19/03 06:10 PM, ID: 8547779Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/19/03 07:01 PM, ID: 8547910Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/19/03 07:17 PM, ID: 8547951Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/19/03 07:42 PM, ID: 8548032Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/19/03 10:41 PM, ID: 8548547Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/19/03 10:42 PM, ID: 8548549Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/20/03 01:49 AM, ID: 8549228Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/20/03 02:47 PM, ID: 8553894Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/22/03 04:42 AM, ID: 8563680Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92