csdnceshi62 2009-01-03 16:14 采纳率: 100%
浏览 428

我应该在 MySQL 中使用 datetime 还是 timestamp 数据类型?

Would you recommend using a datetime or a timestamp field, and why (using MySQL)?

I'm working with PHP on the server side.

转载于:https://stackoverflow.com/questions/409286/should-i-use-the-datetime-or-timestamp-data-type-in-mysql

  • 写回答

27条回答 默认 最新

  • python小菜 2009-01-03 16:18
    关注

    I would always use a Unix timestamp when working with MySQL and PHP. The main reason for this being the the default date method in PHP uses a timestamp as the parameter, so there would be no parsing needed.

    To get the current Unix timestamp in PHP, just do time();
    and in MySQL do SELECT UNIX_TIMESTAMP();.

    评论

报告相同问题?