Return date with Brasilia Timezone

Asked

Viewed 386 times

1

Does anyone know how I put Brasilia’s 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';

1 answer

3


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

Add this code to the first line of your file.

date_default_timezone_set ('America/Sao_Paulo');

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

date.timezone = America/Sao_Paulo

List with all available Zones team.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.