Good day :)

I used to use the php's time () function to get the time / date and stored everything in int, but recently I thought that this is not the best option. Tell me what type of tables is better to choose to store the date and time?

ZY it is assumed that in the future instead of php with bd will work node.js

    1 answer 1

    If the time does not need to be compared and no time samples are needed, then an int is fine.

    In other cases - pay attention to the DATETIME for the date and time. And DATE just for the date. And look at the MySQL functions FROM_UNIXTIME () and UNIX_TIMESTAMP () at the same time - they will be useful.

    • Thanks for the clarification) - LightShock
    • 2
      and, by the way, in many languages ​​there are built-in functions for working with time, which simplify everything very much.
    • Just looking for a function to work with DATATIME. Do not tell me those? Namely, I need functions to get the date in the DATATIME format, and output it in the desired form / format (I can use data () for this, as I suppose). The first link, as I understood it does not suit me, and secondly I somehow did not quite understand why this class is needed .. - LightShock
    • one
      Here, for example: echo date ('dmY', strtotime ('2012-12-30 01:00:00')); - DarkFighter
    • Thanks again) - LightShock