mysql 2037年_Correct way to store MySQL date after year 2037
问题
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"));
回答1:
You probably use a timestamp field to store the dates and not a datetime field.
See mysql documentation on datetime data types, specifically:
The DATE type is used for values with a date part but no time part.
MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The
supported range is '1000-01-01' to '9999-12-31'.
The DATETIME type is used for values that contain both date and time
parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD
HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to
'9999-12-31 23:59:59'.
The TIMESTAMP data type is used for values that contain both date and
time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to
'2038-01-19 03:14:07' UTC.
回答2:
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.
Also, read this. Accessing dates in PHP beyond 2038
(Thanks for catching this problem with 22 years of advance notice. Others will not.)
来源:https://stackoverflow.com/questions/33802337/correct-way-to-store-mysql-date-after-year-2037
mysql 2037年_Correct way to store MySQL date after year 2037相关推荐
- linux笔记本没有insert,无法在Linux中将UTF8插入数据库MySQL(Can not insert UTF8 to Database MySQL in Linux)...
无法在Linux中将UTF8插入数据库MySQL(Can not insert UTF8 to Database MySQL in Linux) 当创建表时,我已经设置了charset = utf8. ...
- mysql内部安装workb_centOS系统中下安装mysql workbench图文详细步骤
类型:数据库类大小:1.7M语言:英文 评分:6.6 标签: 立即下载 MySQL 工作台是为开发人员,DBA和数据库架构师而设计的统一的可视化工具.MySQL 工作台提供了先进的数据建模,灵活的SQ ...
- 使用Docker部署MySQL(数据持久化),将mysql的数据映射到本机磁盘
本文简述如何使用Docker部署mysql,同时持久化数据.我们会用到tutum-docker-mysql 这个项目来搭建一个mysql,省去重头写Dockerfile的时间. 首先我们将tutum- ...
- MYSQL个人学习笔记——数据库介绍、mysql安装配置、数据库操作指令、备份恢复、mysql函数、例题分享
数据库 一.数据库概述 数据库(DataBase,简称DB):长期存储数据的仓库 数据库分类:层次式数据库.网络式数据库.关系型数据库 数据库特点: 1.实现数据共享,减少数据冗余 2.采用特定的数据 ...
- php mysql备份脚本_MySQL备份脚本,mysql脚本
MySQL备份脚本,mysql脚本 mysqlbackup.php: php//备份mysql set_time_limit(0); date_default_timezone_set('PRC'); ...
- MySQL数据库实用教程考核_《MySQL数据库实用教程》郑明秋,蒙连超,赵海侠【pdf】...
内容简介 郑明秋.蒙连超.赵海侠主编的<MySQL数据库实用教程>是作者在多年的数据库开发实践与教学经验的基础上,根据计算机相关专业的职业岗位能力需求及学生的认知规律倾心组织编写的.本教材 ...
- linux停止mysql后又自己启动,Linux上 mysql启动/停止/重启/开机启动/开机禁止启动...
1.查看mysql版本 方法一:status; 方法二:select version(); 2.Mysql启动.停止.重启常用命令 a.启动方式 1.使用 service 启动: [root@loca ...
- mysql数据库名虚拟机_linux虚拟机上装mysql数据库
安装mysql 1.上传已经下载好的mysql安装包到虚拟机下面 2.解压安装包 tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz 3.移动文件到 ...
- MySQL数据库test连接语句_【MySQL数据库开发之二】MySQL 基础语句的书写与操作!...
本篇Himi简单介绍一些MySQL数据库的基础操作: 注:mysql 语句对大小写不敏感,语句以分号";"标识语句结束: 1. 首先使用两个简单的查询语句: 查询当前版本:se ...
- jdbc mysql连接测试_JDBC测试计划-连接mysql
一.测试环境准备 mysql:5.5 JDBC驱动:mysql-connector-java-5.1.30.jar 文件复制到JMeter/lib目录下 JMeter:jmeter-3.2 二.设计测 ...
最新文章
- 《JavaEE开发的颠覆者——Spring Boot实战》是一本好书
- 空间谱专题09:阵列信号建模方法
- python处理表格数据-Python数据处理(二):处理 Excel 数据
- SP2-0110: Cannot create save file afiedt.buf
- ssm使用全注解实现增删改查案例——mybatis-config.xml
- Java知多少(68)面向字符的输出流
- LeetCode 第 24 场双周赛(326/1898,前17.2%)
- android启动画面白屏,Android app启动时黑屏或者白屏的原因及解决办法
- 冷热分离和直接使用大数据库_「系统架构」如何通过分离冷热数据提升系统性能?...
- MUI - 图片预览(perviewimage)的优化
- chattr lsattr
- Google Python Style Guide
- 拒绝“脏”数据——数据质量评估深入剖析
- springboot 打印日志
- Python 处理 PDF 的神器 -- PyMuPDF(下)
- javascript文档_用javascript print js打印文档的最简单方法
- python 爬虫遇到br网页压缩
- 还记得那年大明湖畔的Java 7吗
- 计算机常见的运算符,常见运算符
- 2021-“新“的开源项目之handpose_x(手势识别交互)
热门文章
- SQL Server 触发器
- ADB 学习(4):adb shell (上)
- HTML5+CSS大作业——年会抽奖网页设计(1页)
- DTCMS 网站管理系统
- python求函数零点,在函数零点问题中求解参数范围
- 独家中文汉化AE脚本 Animation Studio v2.3 Win/Mac一键安装版 预设持续更新 支持CC2020
- 秃友进销存标准版内存注册机 Cracked.By.HackWm.
- 谱曲软件-MuseScore
- 第六章 软件项目质量管理
- 推荐几款比较好用的聊天机器人bot开发工具