search

Home  >  Q&A  >  body text

linux - mysql数据库的timestamp为什么从1970到2038的某一时间?某一时间是指什么时间?过了这个时间之后怎么办?

如题。
1 mysql数据库的timestamp为什么从1970到2038的某一时间?
2某一时间是指什么时间?
3过了这个时间之后怎么办?

怪我咯怪我咯2769 days ago731

reply all(3)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:49:02

    First you need to understand what a timestamp is. The timestamp refers to the total number of seconds from 00:00:00 on January 1, 1970 Greenwich Time (08:00:00 on January 1, 1970, Beijing time) to a certain point in time.

    For example, the timestamp of 2015-12-31 17:00:00 Beijing time is 1451552400, which means that the time has passed from 1970-01-01 08:00:00 Beijing time to 2015-12-31 17:00:00 It took 1451552400 seconds.

    There is an online timestamp conversion tool on the Internet: http://tool.chinaz.com/Tools/unixtime.aspx

    The following will answer your questions one by one:

    1. Why does the timestamp of the MySQL database range from 1970 to 2038?
    MySQL's timestamp type is 4 bytes, and the maximum value is 2 to the power of 31 minus 1, which is 2147483647. When converted to Beijing time, it is 2038-01-19 11:14:07. It can be obtained using the online timestamp conversion tool above.

    2. What time does a certain time refer to?
    As above, Beijing time is 2038-01-19 11:14:07.

    3. What should I do after this time?
    1) Use datetime;
    2) Wait until later.

    One last Easter egg: Beijing time 2038-01-19 11:14:07, if some systems are still using MySQL’s Timestamp, or the programming language used by the system uses 4-byte complement integers (such as Java’s int) to represent the timestamp, these systems will be down, and maybe there will be some big news (for example, the aircraft flight system is down, a certain bank system is down), okay, I am just guessing, waiting for that day Bar.

    reply
    0
  • PHPz

    PHPz2017-04-17 13:49:02

    1. Because 32-bit integers can only represent such a long number of milliseconds

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 13:49:02

    1 Because this is the range that unix timestamp (32-bit signed int, seconds since 1970) can represent
    2 1970 + (1<<31 - 1) seconds
    3 No I know, let’s talk about it when we can get there. It is recommended not to use public transportation during that time...

    reply
    0
  • Cancelreply