How to store dates?

Good afternoon. Please do not kick - just learning.

The question is: how to store date in MySQL (and databases in General)?

As I see it: get a timestamp written to the database when you need to - take out and convert as you like.

But heard from many that it is bad form and dates should be stored in DATE, DATETIME and other things, iskluchitelno in their format.

Judge please explain in which cases which option to use better.
Thank you!
July 9th 19 at 11:02
4 answers
July 9th 19 at 11:04
Roughly speaking, a date is a cell in the calendar and timestamp is a moment, a moment in time.
You need to understand what is required in a certain task and choose.

For example.
1. I checked into the hotel on 22 may and moved out on the 26th. Here it is about days, not specific moments.
2. Write in the logs the hit on the website is the moment.
although it is possible the first example of two timstamps to do - Josiane75 commented on July 9th 19 at 11:07
but timestep I can also present a "cell in the calendar". and represent a date as timestep - lost accuracy. - Pierre.Conro commented on July 9th 19 at 11:10
: just timstamp date can not imagine, because in the case of interfering timezones. If we have a hotel in Tokyo and London, in the same time they can be different days. Timstamp this is the point which is common to the whole Earth. Yes, you can make corrections manually, but why? - Evie commented on July 9th 19 at 11:13
July 9th 19 at 11:06
Use unix timestamp eliminates any rake with timzone, seconds coordinate
Thank you. A DATE, DATETIME? What is their advantage? - Josiane75 commented on July 9th 19 at 11:09
: you can use all sorts of things for working with date type, DATE_ADD(dt, INTERVAL 1 DAY) - Pierre.Conro commented on July 9th 19 at 11:12
July 9th 19 at 11:08
In unix t:
+ easy;
the absence of zones;

to date, all the way around.
July 9th 19 at 11:10
If you need to perform operations with dates, e.g. add/subtract a day/hour/week, find the last day of the month, estimate if not leap-year year, find the difference in days between dates, etc. then use datetime (and such things are done quite often).
In fact, in practice, the timestamp is not too many applications, more often used datetime.

Find more questions by tags MySQLSQLWork with date / time