hmm. thanx. This solution requires the user to select his own timezone from a list of options. I suppose I have the other's time zone saved in my MyBB forums database. So I can just use that to correct the time zone. But I would've liked it all to be automated (without any user input). I suppose it's bot very easy to implement though.
It looks like it can be done using some javascript. I don't know enough to do it yet.
*I have decided to just use the settings saved in my mybb forums database. These values are timezone offset and dst (for day light savings). The timezone offset, for example, is 2 for GMT+2, or -5 for GMT -5 and so on.
How can use this to adjust my timestamp I'm reading from my database? I tried taking the hour offset and multiply it by 60*60 to give me seconds and subtract that from my timestamp. But it didn't work. My timestamp is a date format. And if I subtract anything from it it just subtracts from the year, and not from the total seconds since UNIX epoch.
Any solutions? Or perhaps a method to convert timestamp to seconds?
---------- Post added at 01:14 PM ---------- Previous post was at 12:01 PM ----------
I'll just add this here for anyone possibly interested. I found that
strtotime($timestamp)
where timestamp is the timestamp read from mysql database, will convert it to a timestamp (seconds from UNIX epoch).
I can then subtract the timezone offset read from mybb (as seconds) to adjust the time. Then convert back to a string.
Code:
$time = date("Y-m-d H:i:s",strtotime($timestamp) + ($mybb->user["timezone"]+6)*60*60-4*60) ;
The "$mybb->user["timezone"]+6)*60*60" bit takes the timezone offset from mybb. I'm adding 6 to account for the server location. And the "-4*60" bit at the end (which relates to 4 minutes) I just added to fix a discrepancy I picked up between my forums time and my websites time (as saved in the database).