E
E
EvgMul2019-10-10 22:53:52
Database
EvgMul, 2019-10-10 22:53:52

Why is using a timestamp in a DB to store a date wrong?

Hello. I'm reading the Yii2 documentation and I read the following sentence:

For example, in a database you store customers' birthdays in UNIX timestamp format (which by the way is not good design)...

It always seemed to me that this is the opposite, the right approach, because. timestamp is easy to convert to any desired format and return back when saving.
Can you please tell me why this is a bad design and how to implement this correctly?
Thanks in advance to all who respond.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2019-10-10
@EvgMul

because:
1. datatime is clearer and more understandable than a timestamp
2. datatime allows you to store fractions of a second
3. with a timestamp, you lose many convenient functions for working with date / time

H
hint000, 2019-10-11
@hint000

I'll just leave it here
https://habr.com/ru/post/100741/
https://habr.com/ru/post/123461/
https://habr.com/ru/post/61391/
https:// habr.com/ru/post/357704/
https://habr.com/ru/post/273177/
https://habr.com/ru/post/278527/
https://habr.com/ru/post/ 146109/
https://habr.com/ru/company/yandex/blog/463203/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question