32位,64位无符号整型最大值:
2^64-1 = 18446744073709551615
2^32-1 = 4294967295
32位,64位有符号整型最大值:
(2^32)/2-1 = 2147483647
(2^64)/2-1 = 9223372036854775807
减1是因为整型包括0.
64位ubuntu 14.04,php_int_max的值为9223372036854775807,跟mysql中有符号的bigint型的最大值一样.
32位ubuntu 14.04,php_int_max的值为2147483647,跟mysql中有符号的int型的最大值一样.
echo date('y-m-d h:i:s', php_int_max); 返回 2038-01-19 11:14:07
echo strtotime('2038-01-19 11:14:07'); 返回 2147483647
echo strtotime('2038-01-19 11:14:08'); 32位下返回空
也就是说,32位系统上php的time()最大只能返回2038-01-19 11:14:07的时间戳.
字段类型: `posted` int(10) unsigned not null default '0'
32位mysql上(64位mysql也是如此),插入一个比32位无符号int型最大值 2^32-1 = 4294967295 更大的数会发生错误:
update `punbb`.`pb_topics` set `posted` = '4294967296' where `pb_topics`.`id` = 1;
warning: #1264 out of range value for column 'posted' at row 1
不过,mysql可以用8个字节的bigint类型来存储64位整数.
本文永久更新链接地址: http://www.linuxidc.com/linux/2016-02/128479.htm
