I know there are many similar questions, but I didn't find what I exactly need...
So I'm using PHP and I want to show the timestamps from database in the visitor's current timezone.
So far I have done the following:
In PHP, I use $TIME everywhere, which is:
$TIME = time() - date("Z");
This should be an absolute reference to the time, with no dst, am I right?
I get the user's timezone offset with javascript (only at the time of the first visit), and store it in minutes:
var d = new Date();
var tz = -d.getTimezoneOffset();
Of course, the user can set his/her timezone to another one.
When displaying dates from database, I add the stored amount of time to the timestamp:
$timestamp += $TIMEZONE_OFFSET * 60;
And I format it with date()
This seems to be working well, but I wonder what if it comes to dst.
I thought of changing the user's timezone offset somehow automatically, when it comes to dst, but then all the dates would be changed (those too which are not in the dst period). And not every region uses dst, so I'm really confused how to figure this out :\