I've written a very simple script to track clicks on my web site. Links go to my little PHP program, passing a URL as an argument. The script writes a line to a log file and then redirects the user to the specified URL.
The weird thing is that sometimes the times recorded in the log file come out of sequence, and I can't understand why.
Here's the guts of the script:
$output = date("Y-m-d H:i ").getenv("REMOTE_ADDR")." ".$referer.':'.$id." ".$url."\n";
$fp = fopen ("$DOCUMENT_ROOT/../xlog/clicks.txt", "a");
fwrite ($fp, $output);
fclose ($fp);
I would think that since the date function returns the local date/time of the server (right?) that the lines in the log file should always be in strict time sequence. Generally they are, but now and then there will be a log line that's several hours out of sequence with the lines immediately before and after it. What could cause this?