我有一个SQLite DB表包含日期时间字段
数据类型为“timestamp”的真实的值为18696.0
attach image for table structure
因此,我希望将此18696.0值转换为MySQL Y-m-d格式,结果应为2021-03-10
我在网上没有找到任何解决方案。任何帮助将不胜感激。
SQLite时间戳转换为MySQL时间戳。
我有一个SQLite DB表包含日期时间字段
数据类型为“timestamp”的真实的值为18696.0
attach image for table structure
因此,我希望将此18696.0值转换为MySQL Y-m-d格式,结果应为2021-03-10
我在网上没有找到任何解决方案。任何帮助将不胜感激。
SQLite时间戳转换为MySQL时间戳。
2条答案
按热度按时间drkbr07n1#
试试这个:
输出:
1970-01-01 04:58:09
mdfafbf12#
编辑:感谢您更新您的问题与正确的数字和它应该代表什么日期。
您可以使用一个函数将日期添加到Unix Epoch日期上来实现所需的功能:
以
REAL
数据类型存储的SQLite日期将日期存储为Julian Day。从https://www.sqlite.org/datatype3.html开始
真实的作为儒略日数,是指根据格里高利历,自公元前4714年11月24日格林威治正午以来的天数。
PHP有一个
jdtogregorian
函数,其中一个注解有一个方便的函数可以转换为ISO8601日期:结果看起来并不完全正确,在SQLite中它肯定是17889.0吗?