mysql 2037年,正确的方法来存储2037年之后的MySQL日期

I am trying to store in MySQL a date() field a successive date to the year 2037.

For example: 2065-12-01

Problem is that the field is returning: 1969-12-31

What is the correct way to record these values on DB? Should I use VARCHAR?

I compute the date field's value like this:

$future_date = date('Y-m-d', strtotime("+$number_years_to_add years"));

解决方案

It looks to me like you're using the php date and strtotime stuff on a 32-bit platform. Those functions turn into a pumpkin, like Cinderella's carriage, at 03:14:07 UTC on 19 January 2038.

You may wish to check out the new php DateTime class, or upgrade to a 64-bit php implementation.

(Thanks for catching this problem with 22 years of advance notice. Others will not.)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值