Devrais-je utiliser le type de données datetime ou timestamp dans MySQL

Mots clés : mysqldatetimetimestampsqldatatypesmysql

meilleur 1 Réponses Devrais-je utiliser le type de données datetime ou timestamp dans MySQL

vote vote

90

mysql> show variables like '%time_zone%'; +------------------+---------------------+ | Variable_name    | Value               | +------------------+---------------------+ | system_time_zone | India Standard Time | | time_zone        | Asia/Calcutta       | +------------------+---------------------+  mysql> create table datedemo(     -> mydatetime datetime,     -> mytimestamp timestamp     -> );  mysql> insert into datedemo values ((now()),(now()));  mysql> select * from datedemo; +---------------------+---------------------+ | mydatetime          | mytimestamp         | +---------------------+---------------------+ | 2011-08-21 14:11:09 | 2011-08-21 14:11:09 | +---------------------+---------------------+  mysql> set time_zone="america/new_york";  mysql> select * from datedemo; +---------------------+---------------------+ | mydatetime          | mytimestamp         | +---------------------+---------------------+ | 2011-08-21 14:11:09 | 2011-08-21 04:41:09 | +---------------------+---------------------+ 

Questions similaires