Return date with timezone from Brasilia

1

Does anyone know how I put the Brasilia time zone in this code?

$file_path = "file.zip";
$file_update = date ("Y-d-m G:i:s", filemtime($file_path));
$date = date("n/j", filemtime($file_path));
$hours = date("H", filemtime($file_path));
$sec = date("i", filemtime($file_path));
$h = $hours + 3;
if ($h > 12) {
   $h = $h - 12;
   $t = 'PM';
} else {
   $t = 'AM';
}
$file_date = $date . ' @ ' . $h . ':' . $sec . ' ' . $t . ' ET';
    
asked by anonymous 02.10.2016 / 17:36

1 answer

3

Use the date_default_timezone_set () function to set the time used by the functions of dates.

Add this code to the first line of your file.

date_default_timezone_set ('America/Sao_Paulo');

Another way is to set this setting directly in php. Add or modify this line:

date.timezone = America/Sao_Paulo

List with all available time zones

    
02.10.2016 / 17:51