Jump to content



Photo

[MySQL] How to insert the date into MySQL table?


  • This topic is locked This topic is locked
No replies to this topic

#1 Cryo Kinesis

Cryo Kinesis

    Haphost Staff

  • Moderators
  • 128 posts
  • LocationGridania, Eorzea

Posted 05 August 2014 - 04:35 PM

Hi there,

 

Specifying the dates on which the content is entered is of prime importance for the structuring and the chronological arrangement of articles, posts and replies in a dynamic website. MySQL comes with several data types for storing dates in its database system: DATE, TIMESTAMP, DATETIME and YEAR.

The default way to store a date in a MySQL database is by using DATE. The proper format of a DATE is: YYYY-MM-DD. If you try to enter a date in a format other than the Year-Month-Day format, it might work but it won’t be storing the dates as you expect.

In order to run a MySQL Insert command and add the current date into your table you can use MySQL’s built-in function CURDATE() in your query.


Cryo%20Kinesis%20Haphost%20Sig2.png





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users