1

Now, before you mark this as a duplicate, please note that all the useful answers in the possible duplicate provide functions which work in relation to the current system time, which I cannot accept.

What I want, is that the current time in, say, for example, New York, be consistent to all users, no matter what their time settings are.

For example, I have two computers here, and one is 3 seconds behind the other, and this leaves an unacceptable gap, as my task involve pinpoint precision (slightly exaggerated, but you know what I mean).

How can I overcome this? Must I get the server time and somehow convert it? If so, I'm using PHP.

4
  • Can you explain a bit more clearly what it is you need to accomplish? Commented Feb 12, 2013 at 10:48
  • datetime.settimezone Commented Feb 12, 2013 at 10:50
  • possible duplicate of JavaScript NTP time - You're wanting to sync possibly inaccurate clocks client-side, for which NTP is the right protocol. On top of that you need to do your timezone calculations. Commented Feb 12, 2013 at 10:54
  • Not a dup, and that link is bad because it claims NTP but really is just passing the time in json and not using the NTP protocol at all. Commented Feb 12, 2013 at 17:02

2 Answers 2

1

Hope to not be wrong but javascript is loaded on user machine, not on the server so you will allway get the visitor date/time using javascript. you can use php to get the date/time because is loaded on the server and pass the dates to javascript.

Hope this help

Sign up to request clarification or add additional context in comments.

Comments

0

You need to use a timezone library to do this in JavaScript. See my answer here.

The scripts are small, but because they require the timezone database, it can get unwieldy for a client application. You're probably better off doing the conversion server side. Perhaps the pytz library will be useful to you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.