0

I have a script that outputs some data along whith a tag like "added 1 hour ago" . Now, if the timezone on the server is the same as the user;s timezone it will do it fine.

I know that user's timezone can be obtained by JavaScript, but how do I sent offset to the PHP script before the data is displayed? a body onload function? append a parameter to the main page that will show the content?

timezone on server is set to UTC

thx

2
  • 3
    Why is this important? If the user is in another timezone, the post is still 1 hour old. Use the server time for both. Commented Mar 2, 2013 at 5:48
  • 1
    Check this link stackoverflow.com/questions/8090549/… Commented Mar 2, 2013 at 5:52

1 Answer 1

2

You can get the user's timezone in javascript and then make a ajax request to some file and in that file you can do like this

$tz = $_POST['tz']; date_default_timezone_set($tz); echo date('Y-m-d H:i:s'); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.