Capture visitor's local time [duplicate]

0

Hello, for security reasons I need to get the time the page visitor entered, but the system apparently is taking the time from the server.

IP: [XXX.XXX.XXX.XXX] Date: [03-07-2017 - 14:05:49] (Local time 11:05)

I'm using the following code

$ip = $_SERVER['REMOTE_ADDR'];  
$data = date("d-m-Y - H:i:s"); 

What could I use to get Brazilian time (Brasilia official time)?

    
asked by anonymous 03.07.2017 / 16:06

1 answer

3

Normally the log time is the server's own time, as said @Diego Vieira, several users may have different times, but answering your question

  

What could I use to get the Brazilian time (Brasilia official time)?

If you just wanted a specific date in another timezone, that of São Paulo, for example

$dt = new DateTime('now',new DateTimeZone('America/Sao_Paulo'));
echo $dt->format('d-m-Y - H:i:s');

Or you can use the date_default_timezone_set function to set the app's default timezone

date_default_timezone_set('America/Sao_Paulo');
    
03.07.2017 / 16:22