Jump to content

Local computer time


icekat83

Recommended Posts

Hey,

 

I'm trying to code a page which is supposed to bring up the time of a person's computer. Is this possible without majorly complicated coding? I'm good with GMT offsets and stuff but I don't know how to get the time of a person's computer. I don't want other stuff, just the time so I can edit the time based on where they are.

 

I don't know if I'm making sense so here's an example...

 

If someone does a forum post at 2pm Sydney time but it's 5pm Perth time. How can I make it so that someone in Perth sees 5pm but someone in Sydney sees 2pm...without them manually telling me their timezone?  :shrug:

 

I read about using IP addresses but don't know much (Ok anything) about this , any hints or good sites to view would be appreciated? Or the answer if it's not too complex.  :shy:

 

Preferably I'd like to get the time in the 11 digit "time()" format so I can use it in tables and translate it with an existing function.

 

IceKat

Link to comment
Share on other sites

You could use javascript to easily get the users time, and store it as $_SESSION['time']. As long as you don't have a problem with users being able to change their time... or if their time is incorrect then their true location wouldn't match your function's location for them.

 

Link to comment
Share on other sites

Better yet,

<noscript><?php echo "Server Time: ".date(format); ?></noscript>

 

Edit, I have to admit I haven't been fair to you. You mentioned google analytics, which made me think duh -> ip -> trace - > timezone.

 

$region = geoip_region_by_name($_SERVER['REMOTE_ADDR']);
$zone = geoip_time_zone_by_country_and_region($region['country_code'],$region['region']);

 

However this method is not as accurate as you'd like, with javascript->ajax->php more accurate, and being the most accurate: asking the user.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.