2
I saw similar questions, but none with answer, my date is coming so from the bank 2017-05-05T00:00:00+00:00 when I try to make a date(’d-m-Y',strtotime($data)); it comes so 04-05-2017, has it come 05-05-2017? Why does this happen? Why does she return one day?
echo date('d-m-Y',strtotime($publicacao['dataPublicacao']));
Here takes from the bank through the publish token and id and returns a json
function getSinglePublicacao($id){
session_start();
include_once "token.php";
$token = getToken($_SESSION['username'],$_SESSION['password']);
ob_start();
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'http://politizar.azurewebsites.net/api/cadastro/publicacao/getSingle/'.$id );
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token ) );
curl_exec( $ch );
$data = ob_get_contents();
ob_end_clean();
$httpCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
curl_close( $ch );
return json_decode($data, true);
}
And here was my attempts, Bs the return of publishing['dataPublication']; returns 2017-05-05T00:00:00+00:00
e o resto retorna a data faltando um dia
$partidos = listarPartido($token_access);
$idPublicacao = $_GET['idPublicacao'];
$publicacao = getSinglePublicacao($idPublicacao);
print_r($publicacao);
$cidades = listarCidades($token_access);
echo str_replace("-","/",date('d-m-Y',strtotime($publicacao['dataPublicacao'])));
echo str_replace("-","/",date('d-m-Y',$publicacao['dataPublicacao']));
echo "<br>";
echo date('d-m-Y',strtotime($publicacao['dataPublicacao']));
echo "<br>";
echo $publicacao['dataPublicacao'];
In the Ideone the result was 05-05-2017. Are you sure that the value is coming from the database? What version of PHP?
– Woss
The version is 5.4 and yes it’s coming from the bank @Andersoncarloswoss will be something I did wrong?
– Anderson Henrique
look at how Anderson said: https://ideone.com/Uf7nZ3 it’s not as if the value returned from the database is like this, and then it’s not php version maybe it’s confusion or even typo, take a better look!
– novic
And which is the Timezone configured? The information stored in the database and in PHP are the same?
– Woss
I don’t know @Andersoncarloswoss how I put the same php?
– Anderson Henrique
@Virgilionovic No... it’s not a typo because I copied and pasted the return here... it’s coming anyway
– Anderson Henrique
Strange @Andersonhenrique very strange. I believe I do not know can be wrong has nothing to do with Timezone, because the date is not requested from the system the date is a value brought from the bank. Now I’m curious
– novic
You have the full chunk of that code?
– novic
I do have @Virgilionovic I will edit the question 1 minute
– Anderson Henrique
Edited by @Virgilionovic
– Anderson Henrique