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
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');