mysql函数unix_timestamp如何处理1970.1.1以前的数据?
高洛峰
高洛峰 2017-04-17 16:10:09
0
2
707
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
Peter_Zhu

Then there is no way to use TIMESTAMP
You can consider using the DATETIMEtype

DATE range '1000-01-01' to '9999-12-31'

DATETIME'1000-01-01 00:00:00' to '9999-12-31 23:59:59'

TIMESTAMP '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC

PHPzhong
-- N秒前
SELECT TIMESTAMPADD(SECOND,-3600,'1970-01-01 00:00:01')
-- >> 1969-12-31 23:00:01

-- 2天前
SELECT TIMESTAMPADD(DAY,-2,'1970-01-01 00:00:01')
-- >> 1969-12-30 00:00:01

# FRAC_SECOND。表示间隔是毫秒
# SECOND。秒
# MINUTE。分钟
# HOUR。小时
# DAY。天
# WEEK。星期
# MONTH。月
# QUARTER。季度
# YEAR。年

Make sure the negative number you save is relative to 1970-01-01 00:00:01, there is no problem in this calculation

select TIMESTAMPADD(FRAC_SECOND, table.create_time, '1970-01-01 00:00:01') as `create_time` from table
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!