PHP script to pull time from the SERVER not the the end user?

Steven K

New member
Hi,
I am running a web server from home for a hobby. I have the following script written record IP user data with time.

<?php
$v_ip = $_SERVER['REMOTE_ADDR'];
$v_date = date("l d F H:i:s");
$v_page = $_SERVER['REQUEST_URI'];
$u_ref = $_SERVER['HTTP_REFERER'];

$fp = fopen("iplog.html", "a");
if ($v_ip != "192.168.1.1") {
fputs($fp, "<b>IP:</b> $v_ip - <b>PAGE:</b> $v_page - <b>DATE:</b> $v_date - <b>REFERER:</b> $u_ref\n<br>");
}
fclose($fp);
?>

The only problem is that the time is recorded from the web user's time settings. It is NOT pulling the HTTP request time from the server itself. For example, if the time in Germany is 5 AM and my server time is 1 PM the this script will record the time as 5 AM, not 1 PM. I tried date_default_timezone_set('UTC'); but then again it is pulling the time from the user not from my server.

The reason why I need to get the time from my server is that a I have no idea the time zone they visit the site so the time recoded will be inaccurate.
Oh and THANK YOU for the help.
 
Back
Top