Server-side time refresh

Source: Internet
Author: User
Server-side time refresh mobile game server front-end

I want to know if my younger brother is a mobile game developer.
Front-end request time on my server
I should pass it to him in real time on my server
So how can I refresh myself in real time?
Are there any solutions?
Use as few resources as possible


Reply to discussion (solution)

I don't understand. can I directly use the time () function in php to directly obtain the timestamp of the current time? Format the output to the front end with date ().

Is there anything in it...

Because the game time must go through the server time and cannot go through the client, the server must always refresh the time to the front end.
When a client player changes the mobile phone time, it is equivalent to the game time.
For example, some games ask you to draw a prize once a day and prompt you to leave XX hours, XX minutes, and XX seconds before the next lucky draw.
At this time, I have to give it to the server.
Visually Speaking: each time the front-end sends a request to me, "Is it time ?" I just need to tell him "to" or "not .. If he asks me after a while that I have to refresh my own time to catch up with the frequency of his requests, then he probably means

Your "visualization" is also a solution, but it is not that you refresh the time (time exists objectively) but that you express it in your way.
Generally, this is not the case. Instead, the server time is sent to the user at the beginning, which is used to calculate the time difference between the user time and the server time. There is a lot of code for this js countdown. you can find it.

That's right.

In addition, you can determine whether it is within the time range when you really "receive the prize ".

What time () is obtained on the server always the current server time? @ Xuzuning

I asked him about the bat file in a batch.
What is the stop loop? can this solution be used --

That's right.

In addition, you can determine whether it is within the time range when you really "receive the prize ".

What time () is obtained on the server always the current server time? @ Xuzuning

Time () obtains the server time. You can do this: Pass the server time at the beginning, and take the server time as the standard during verification. it doesn't matter how Rice is stored on the client side, after all, the key factor for determining success is in the hands of the server.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.