0
Hello.
I have an application that I’m building in cakephp. The application keeps showing the date and time on the page, but it’s computer time. How do I get the time of some server or internet link?
0
Hello.
I have an application that I’m building in cakephp. The application keeps showing the date and time on the page, but it’s computer time. How do I get the time of some server or internet link?
0
You can use the following PHP function to change the time zone: http://php.net/manual/en/function.date-default-timezone-set.php
Browser other questions tagged php cakephp
You are not signed in. Login or sign up in order to post.
The time of PHP(cake) comes from the server that is configuring with some Timezone or UTC, to pick the client’s time will need javascript, remember that this is not reliable.
– rray
What I’ve seen them do (I’ve never needed it exactly this way), and it’s good, is to load the server time, and increase it with JS, by the difference of the client clock. Just don’t trust the "interval", because it accumulates offset. That is, it sends the time, the JS picks the server time, and increments with the offset of the client clock. In the client the time may be different, but in theory, time advances at the same speed :). If you need a lot of precision, then you will need a more robust mechanism (calculate the time of an ajax, use websockets etc), but I think it’s too much if it’s just a watch.
– Bacco
@Bacco is what I want to do. Take the external time and not the pc time. If the pc has the wrong clock, cakephp will also show wrong.
– André Nascimento