DECIMAL length for microtime(true)?

后端 未结 4 1032
轮回少年
轮回少年 2021-02-14 03:48

I want to store PHP\'s microtime as my timestamp in MySQL.

I\'ve been told it\'s best to store it in DECIMAL, but I can\'t find an ideal size.

Does

4条回答
  •  北海茫月
    2021-02-14 04:34

    That depends on the precision you need. If milliseconds are enough for you, and you don't expect any runtimes larger than 999999 seconds you could use DECIMAL(10,4). You can fit it to your needs this way.

    About the theoretical maximum, it is limited by the size of a float on your system (32bit, 64bit). See PHP Float for details. But as I said, that is theoretical. No timer will give you the time in that precision.

提交回复
热议问题