Cómo convertir timestamp a datetime en MySQL?
Cómo convertir 1300464000
a 2011-03-18 16:00:00
en MySQL?
5 answers
Utilice el FROM_UNIXTIME()
función en MySQL
Recuerde que si está utilizando un framework que lo almacena en milisegundos (por ejemplo, la marca de tiempo de Java) tiene que dividir por 1000 para obtener la hora Unix correcta en segundos.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-10-18 14:26:48
DATE_FORMAT(FROM_UNIXTIME(`orderdate`), '%d-%m-%Y') as "Date" FROM `orders`
Esta es la solución definitiva, si la fecha está en formato codificado como 1300464000
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-09-08 13:23:46
Para responder el comentario de Janus Troelsen
Use UNIX_TIMESTAMP en lugar de TIMESTAMP
SELECT from_unixtime( UNIX_TIMESTAMP( "2011-12-01 22:01:23.048" ) )
La función TIMESTAMP devuelve una Fecha o una Fecha y no una marca de tiempo, mientras que UNIX_TIMESTAMP devuelve una marca de tiempo unix
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-02-21 17:32:40
SELECT from_unixtime( UNIX_TIMESTAMP(fild_with_timestamp) ) from "your_table"
Este trabajo para mí
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-14 11:06:46
Puede usar
select from_unixtime(1300464000,"%Y-%m-%d %h %i %s") from table;
Para una descripción detallada acerca de
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-24 07:44:55