Forum Moderators: coopster

Message Too Old, No Replies

Determining local time, and time in different time zone

         

madmatt69

9:04 pm on Dec 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey all,

I figured this should be a fairly easy thing to do, but I'm having trouble.

Basically I'm looking for a way to display on the site "Your time" which will display the time of the user's computer, and then "Local time in Brazil" for example, which will then display the local time in brazil, and compute the time difference (i.e 4 hours or something).

The thing is I didn't want to have to program some big huge function - I figured this would be really easy, and it seems it is using php5, but I'm using php 4.

I could manually define every time zone and subtract or add the number of hours, but it seems there should be some sort of function already out there that does this, and takes into account time zones.

I thought about pinging time servers as well, but I'm thinking there needs to be an easier solution.

Am I overcomplicating things? If anyone can point me in the right direction, it'd be much appreciated!

PHP_Chimp

8:41 pm on Dec 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As you are looking for something that needs some client side information javascript would be a much better bet.

You could try to examine the IP address and then find the time zone based on the IP address of the request. There are problems with that, as IP addresses are not always the actual IP address of the person (all of those proxies out there).

So you would be better with a javascript code as this will be able to take the time from the client environment. So as long as the client has the correct time you will be able to use that...if the client doesnt have the correct time on there system then you will obviously get the incorrect time.