1
I’m having a problem returning json with date and time the code is as follows:
<?php
$sql = "SELECT CRED_NUMERO, MOV_DATAHORA FROM APOIO.LOG_CREDENCIAL_APOIO A WHERE A.CRED_NUMERO = 10734568 AND TRUNC(MOV_DATAHORA) = TRUNC(SYSDATE)";
$conn = oci_connect('xxx', 'xxx', '127.0.0.1/DBUAM');
$dados = oci_parse($conn, $sql);
oci_execute($dados, OCI_DEFAULT);
$linhas = array();
while($l = oci_fetch_assoc($dados)){
$linhas[] = $l;
}
$json = (json_encode($linhas));
echo $json;
?>
The result of json is this:
[{"CRED_NUMERO":"10734568","MOV_DATAHORA":"26-AUG-15"},{"CRED_NUMERO":"10734568","MOV_DATAHORA":"26-AUG-15"}]
If you notice the result of JSON shows only the DATE and what matters most to me is time. How to format?
I think your problem is more related to the database you are using and your SQL query. You can tell us what your database is?
– Raimundo Norberto
The database used is Oracle
– Victor Sued
In select, I believe you need to format the date different from the default, doc
– rray
@Victorsued Testa switch
TRUNC(SYSDATE)
forTO_DATE(SYSDATE, 'dd/MM/RRRR HH:mm:ss')
– Jéf Bueno