[PHP] Returning client time and date

Soldato
Joined
15 Jan 2004
Posts
10,198
How do you return the time and date of the person browsing a page?

Do you need to format time() to the users timezone? As it keeps returning UTC time (hour behind)?
 
Yeah, but that only works for people in the UK. Is there anyway to detect the users timezone, or would I have to use javascript?
 
Either use Javascript or allow them to choose their own timezone and set a session/cookie value that stores it, defaulting to GMT for those users who haven't set a custom timezone.
 
toastyman said:
Alternatively you could use an IP2L (IP to Location) file, but its a lot of work just to do this...
Indeed, but even then you run into issues with users on proxies and big networks like AOL which won't resolve to the right geographical location. Better to go with a default that is right for the site's own timezone, and then let the user switch if they desire.
 
Back
Top Bottom