Jump to content

Is there a way?


Love2c0de

Recommended Posts

To create a live updating clock with PHP? Are there variations depending on where a server is hosted which can make it inaccurate for a user? For example is someone lives in east USA, they may be connected to a server in mid america which would create a time difference.... I live in south UK and have been connected to a server in Scotland before so that distance across america could cause a time difference for someone.

 

I'd rather use a serverside language rather than javascript but I know a Javascript clock is based on users local time so it will be accurate.

 

I've searched google and php.net and can't seem to find anything relating to PHP timers/clocks......

 

Thank you for your thoughts.

 

Kind regards,

 

L2c.

Edited by Love2c0de
Link to comment
Share on other sites

Almost all competent technical organizations use some sort of time synchronization, and set all their servers to use UTC. Some of the things you seem to be alluding to are locale based. If you know what the user's locale is, you can take a UTC datetime and convert it relative to their timezone. PHP's datetime object when combined with the timezone object is fully featured in allowing you to convert a UTC datetime to whatever timezone you want.

 

Clearly a clock, should be running on the user's workstation. You could implement a flash, java or javascript based clock that is initialized to a known datetime value (with timezone string) and then display it. With that said, I don't really know (outside of a worldclock type console) what an application of this idea would be.

Link to comment
Share on other sites

Thank you for your replies.

 

I know it seems redundant to create a clock and display it on a webpage and I completely agree with you. I just wanted to add some content to my left sidebar on my website and was struggling for ideas!

 

Thanks for your advice, I'll have a look into those techniques.

 

Regards,

 

L2c.

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.