02.03.2018, 15:33
Quote:
Here is the script. Updating time and date - every second. Tell me, is there a load on the server due to this timer? And is there an easier solution for setting the clock / date on the server?
And another question, tell me how to change the time zone on the server? SetWorldTime does not help ... PHP код:
|
You could however strip Date and Time since the Date only changes once a day, but that doesn't really make a difference.
One suggestion though, you can use format specifiers to show "2" as "02" by doing
Код:
format(string, sizeof string, "%02d:%02d:%02d", hours, minutes, seconds);
Furthermore the string size can be much lower. Neither of the strings is going to reach even 10 characters.
To simulate a different timezone you can add/subtract X from the hour variable, and check if the new hour wrapped to another day (eg. hour 25 would be 1:00:00 and the next day, hour -1 would be hour 23 of the previous day).