简体   繁体   中英

How to properly insert date into MYSQL database using php?

I want to store and display date in this format "1.1.1990", (dmY)

I've got a date column in my database with these settings

TYPE: DATE

Browser display transformation: Date Format(text/plain: Dateformat)

Browser display transformation options: 0,'%j.%n.%Y','local'

My query goes as :

INSERT INTO table VALUES(STR_TO_DATE('1.1.1990', '%e.%c.%Y'))

So far the query is accepted but a blank field is displayed in database

Only other thing i could get is without using STR_TO_DATE to add a default date as 1.1.1970

  1. You have to set the column in date type
  2. You can ensure the date is wellformed: select STR_TO_DATE('1.1.1990', '%e.%c.%Y');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM