mysql初始时间1970_MySQL:使用1970年以前的日期

bd96500e110b49cbb3cd949968f18be7.png

I'm working on a church site wich has many events before 1970, these events starts from 1001 to today, how can I store the dates in MySQL?

$y = $_REQUEST["year"];

$m = $_REQUEST["month"];

$d = $_REQUEST["day"];

$date = date("Y-m-d", "$y/$m/$d");

This works fine only for dates after 1970, how can I store dates before this year?

What kind of datatype should I have in MySQL? Now I've set my column to date type

解决方案

DATE is fine. It can store values from 1000 to 9999 AD.

The DATE type is used when you need only a date value, without a time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.

It's different with PHP's old-style date functions (date(), strtotime()....) these work with UNIX timestamps and, when using 32-bit values, are limited to a date range from 1970 to 2038.

To work with date values beyond that, work with PHP 5's new object-oriented DateTime class.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值