My webserver's located in Switzerland, so server time should be GMT+1h. Now what will a visitor see, when I echo something like date('Y-m-d h:i:s', time())? Will a visitor from say the U.S. see Switzerland's time, or will he see e.g. GMT-8h (I guess so...)? Thx!
Your php-program runs on the server in Switzerland and does not know anything about the location of your visitors. The time shown will be the Swiss time. Jean-Luc
You will have to adjust for timezones, or use clientside scripting to get the users local time to display. Good luck...
Hmmm... how can I do this - preferably on the server side? Isn't there information about a client's timezone included in the Http-Request?
Use geolocation to find the clients timezone from the IP and calculate the time difference from them to your web server.
It is not easy to do it on the server and I don' t even see the benefit of doing it on the server, except if you need the visitor's local time for something else, of course. I would suggest you to google for JavaScript clock. There are plenty of short JavaScript examples available. Jean-Luc
Thing is, I have the date of an user event stored in my database. So I'd like to convert that date into the user's timezone. I guess Javascript is no option then, is it?
Just a thought, but if there's any need to keep the events in order wouldn't it make more sense to have everything running based on the same time zone?
You can use javascript to get the users time then an AJAX call to update the database if thats what you are looking for.
Well, no. My tool is a kind of web analytics tool that logs search terms. So the user includes a line of javascript on his pages, and the tool logs the search terms used by his search engine visitors. Along with the search terms the server then writes the date&time when a term has been logged into the database. When displaying the latest search terms, the user will want to see the time of his timezone, not the one of the server I guess...