B
B
bedolazhka2019-11-25 18:54:16
HTML
bedolazhka, 2019-11-25 18:54:16

DATETIME or TIMESTAMP?

I got confused while reading the description of these formats regarding the time zones.
Which of these formats should I use so that, regardless of the user's time zone, the state of one time zone always remains in the database?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
AlexKeller, 2018-12-03
@Blackmilk4

Yes, whatever you like, you can use the background for the menu item ( https://jsfiddle.net/jorcv0sp/), you can use the border for the icon, you can use before/after

D
DevMan, 2019-11-25
@bedolazhka

use datetime until you are sure otherwise.
timestamp in muscle:
- limited to 1970-01-01 from below and 2038-01-19 from above (accordingly, not very suitable for storing, for example, historical dates or birthdays)
- display depends on the server time (when restoring on another server, it may happen not what was expected)

K
Kalombyr, 2019-11-25
@Kalombyr

DATETIME - does not depend on the time zone, output as added.
That's just the time zone of the "user" here, as it were, has nothing to do with it, but depends on the settings of the operating system, MySQL or the session.
PS in the future, if you need to work with intervals (selection by day, month, etc.) it's easier and faster through TIMESTAMP

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question