mysql date example

Example 1: mysql format date

DATE_FORMAT(date, format)
-- E.g.
SELECT DATE_FORMAT(dateField, '%m/%d/%Y') FROM TableName;
-- See https://www.mysqltutorial.org/mysql-date_format/ for available formats

Example 2: how to assign date field for table in mysql

CREATE TABLE people (
    id INT AUTO_INCREMENT PRIMARY KEY,
    first_name VARCHAR(50) NOT NULL,
    last_name VARCHAR(50) NOT NULL,
    birth_date DATE NOT NULL
);

Example 3: mysql timestamp format

INSERT INTO ... VALUES ('YYYY-MM-DD HH:MM:SS');

Tags:

Php Example