I want to get details of user when he registers with my website for security reasons. I need ip and date and time I guess. Is there anything else I need to cache while registering? How to get ip,time and date? And time will be in which timezone? I want it in GMT +5:30 means asia - culcutta. Thanks in advance.

And i want to save user log in time. Any help about this will be thankful.

6 Years
Discussion Span
Last Post by kirtan_thakkar
$date_time = date("l j F Y  g:ia", time() - date("Z")) ;
echo "$date_time   IP: $IP";

The $_SERVER superglobals provide a load of useful information.

$ip = $_SERVER['REMOTE_ADDR'];     // The IP address from which the user is viewing the current page.
$time = $_SERVER['REQUEST_TIME'];  // The timestamp of the start of the request.     
$port = $_SERVER['REMOTE_PORT'];   // The port being used on the user's machine to communicate with the web server.   
$browser = $_SERVER['HTTP_USER_AGENT']; // Contents of the User-Agent (Web browser): header from the current request

// etc...

See here

Edited by nonshatter: n/a



Use this to see what information can be accessed and then decide what you want to use and access it like any other array

foreach ($_SERVER as $key => $item)
  echo "<li><b>$key:</b> $item<br/></li>";



Thank you all. It done my work. But I have a last question. What would be better format to store user's login time? Like 1296143233 or Thursday 27 January 2011 3:47pm? Thank you. And how to convert 1296143233 to Thursday 27 January 2011 3:47pm. I think first format will save the disk space. Please help.


I generally tend to use a Unix timestamp, but I'm not really sure what the 'best' format is. This link explains mysql date formats

You can convert a unix timestamp to a human-readable format using the date() function. You can format the date format to your liking:

$timestamp = 1296143233;
$formattedtime = date("d/m/y", $timestamp)

Or to turn a date back into a timestamp, use strtotime():

$date = "01/01/1970";
$date2timestamp = strtotime($date);

Edited by nonshatter: n/a


Hey thanks.... My work will get done by this.. Thank you so much to all of you who helped......

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.