A
A
Alexey Semyonov2018-02-09 16:36:51
SQL
Alexey Semyonov, 2018-02-09 16:36:51

In the database, store the time in the form of datatime or unix?

Question for an experienced developer. Prompt in what form it is better to store time in a DB? I work on several projects, somewhere the time is stored in datatime format, and somewhere in unix.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Tsvetkov, 2018-02-09
@tsklab

In the format of a field with the "date" type.

I
ivankomolin, 2018-02-09
@ivankomolin

The main difference in them is that datetime does not depend on the time zone, and unixtime will return different times depending on the time zone when received, so when using database clients in different time zones, unixtime is more convenient.
Well, of course, the size in bytes is different, with a gigantic amount of data, the choice is made in favor of unixtime.
But if you store unixtime not in the int type fields intended for this and return it without using the built-in database functions to convert to a date, then all the charm of unixtime except for the size is lost.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question