正确的方法来存储2037年之后的MySQL日期 [英] Correct way to store MySQL date after year 2037

查看:403
本文介绍了正确的方法来存储2037年之后的MySQL日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在MySQL中将 date()字段存储到 2037 年的连续日期.

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

例如:2065-12-01

问题在于该字段正在返回:1969-12-31

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

在DB上记录这些值的正确方法是什么?我应该使用 VARCHAR 吗?

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

我这样计算date字段的值:

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

推荐答案

在我看来,您好像在32位平台上使用php datestrtotime一样.这些功能变成了南瓜,就像灰姑娘的马车一样,在2038年1月19日世界标准时间 03:14:07 .

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.

您可能希望检查新的php DateTime 类,或升级到64位php实现.

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

另外,请阅读此内容. 在PHP中访问2038年以后的日期

Also, read this. Accessing dates in PHP beyond 2038

(感谢您提前22年发现此问题.其他人不会.)

这篇关于正确的方法来存储2037年之后的MySQL日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆