a1exlism
10/26/2016 - 4:54 AM

MySQL_timestamp.sql

-- create
CREATE TABLE db.table (
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  message VARCHAR(200) NOT NULL ,
  create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
  update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- order http://stackoverflow.com/questions/12100308/how-to-order-by-time-stamp-in-mysql
SELECT * FROM table
ORDER BY STR_TO_DATE(`timestamp`,'%m/%d/%Y %h:%i:%s %p');