Breaking query fields

1

I'm doing a search with mysql, where the return is a DATE field, I need to break this field into DAY, MONTH, TIME, SECONDS and put each one within a variable, I'm not able to do this, a query but it is returning

  

Resource id # 18

     

Resource id # 19

The query I made is as follows:

SELECT DATE(DAT_EHORA_EVENT) FROM tbl_CLIENTES_AGENDA WHERE COD_SEQUN_AGEND = '".$linha['COD_SEQUN_AGEND']."'
    
asked by anonymous 02.07.2015 / 22:58

1 answer

1

Solution in MySQL

SELECT YEAR(DAT_EHORA_EVENT), 
       MONTH(DAT_EHORA_EVENT), 
       DAYOFMONTH(DAT_EHORA_EVENT), 
       HOUR(DAT_EHORA_EVENT), 
       MINUTE(DAT_EHORA_EVENT), 
       SECOND(DAT_EHORA_EVENT)
FROM tbl_CLIENTES_AGENDA WHERE COD_SEQUN_AGEND = '".$linha['COD_SEQUN_AGEND']."'

Solution in PHP

$hora = strtotime($row["DAT_EHORA_EVENT"]);
echo date('Y', $hora); // ano
echo date('m', $hora); // mês
echo date('d', $hora); // dia
echo date('h', $hora); // hora
echo date('i', $hora); // minuto
echo date('s', $hora); // segundo
    
02.07.2015 / 23:13