code for getting IP and system date and time .

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rrn
Forum Commoner
Posts: 46
Joined: Wed Apr 15, 2009 7:54 am

code for getting IP and system date and time .

Post 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..
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
rrn
Forum Commoner
Posts: 46
Joined: Wed Apr 15, 2009 7:54 am

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

Post by rrn »

thank you for the suggestions , it worked ,
Thanks a lot.
Post Reply