How to express date and time in the format "Y-m-d \ TH: i: sP", with zone UTC-03: 00

1

Following the documentation, I'm trying to represent the date in the following format:

  

2017-01-07T11: 20: 00-03: 00

Code:

$dt = $_POST['data-emissao'];
$date = new DateTime($dt, new DateTimeZone('America/Sao_Paulo'));
$data= $date->format("Y-m-d\TH:i:sP");
echo $data;

And I'm getting:

  

2017-01-07T13: 32: 00-02: 00

Reference : link

    
asked by anonymous 07.01.2017 / 16:41

1 answer

2

Hello, the return is correct, we are in Daylight Saving Time. You have set the Time Zone "America / Sao_Paulo" which is currently -02: 00 instead of -03: 00.

If you want to get always -03: 00 regardless of Daylight Saving Time then the simplest is to use a literal string -03:00 , since it makes no difference to Daylight Saving Time. >     

07.01.2017 / 18:47