Page 1 of 1

code for getting IP and system date and time .

Posted: Sun Feb 21, 2010 6:26 am
by rrn
in my php page i have added code for getting IP

Code: Select all

 if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }
 
 
but i am not getting the real IP . HOW TO GET THE REAL IP ??
give me a solution..

i have got one more problem..
to get the system date and time .added the following

Code: Select all

$date = date(' d/m/Y h:i:s A');
 
but the time am getting is 3 hours behind the system time , i need to get the system time , how??
suggestions plz...thank u..

Re: code for getting IP and system date and time .

Posted: Sun Feb 21, 2010 9:22 am
by requinix
1. You're misunderstanding something. Not sure what. That code should get you the client's IP address. What are you trying to get?

2. Use

Code: Select all

$date = date(' d/m/Y h:i:s A T');
and compare the timezone with the one you expect to see.

Re: code for getting IP and system date and time .

Posted: Mon Feb 22, 2010 2:27 am
by rrn
thank you for the suggestions , it worked ,
Thanks a lot.