I have a cronjob that calls a PHP file via CURL every hour from one of my computers. When the file is called, the PHP code retrieves the server time, since it should record it in a database field in HH:MM format.
Client and server are not perfectly synced, so, when the client calls the PHP file, it can happen that for the client it’s 14 o’clock, while for the server it’s still 13:59. 13:59 is not acceptable for my db, since I should have always 14:00, 15:00, 16:00 and so on.
I can’t send parameters via CURL because of an unsolved issue with time and my computer AND I can’t change the server time.
The only thing I could try is to adjust the time retrieved from PHP, and, when it’s 13:59 (or even 14:01), adjust and save it as 14:00. Is there any PHP magics to solve this problem? My idea is to convert the time to 13,59 (or 14,01), then round them in some way, but maybe there are better options.
Any help is appreciated.
The simplest way to get the nearest hour in an
HH:MMformat string that I can think of is:FIXED (again)