I want to fill out some null dates with default dates, which should be the epoch date.
我想要填写一些默认日期的空日期,这应该是纪元日期。
eg set updateDate = somethingtoconvertEpochDateToDateTime(numberofMillisSinceEpoch)
设置updateDate = somethingtoconvertEpochDateToDateTime(numberofMillisSinceEpoch)
1 个解决方案
#1
4
The MySQL DATETIME
only represents times to one second resolution, so you mat as well divide your 'millis' by 1000 and use
MySQL DATETIME仅表示一秒的分辨率,因此您也可以将“millis”除以1000并使用它
updateDate = FROM_UNIXTIME( numberofMillisSinceEpoch / 1000 )
If you really need to store date-time information to higher resolution, you could store the milliseconds since epoch in a BIGINT
and roll your own conversion functions.
如果您确实需要将日期时间信息存储到更高的分辨率,那么您可以将纪元以来的毫秒存储在BIGINT中,并滚动自己的转换函数。
If you need to back fill with the current date time (i.e. now) you can use the UNIX_TIMESTAMP()
function with no argument.
如果需要返回当前日期时间(即现在),可以使用UNIX_TIMESTAMP()函数,不带参数。
#1
4
The MySQL DATETIME
only represents times to one second resolution, so you mat as well divide your 'millis' by 1000 and use
MySQL DATETIME仅表示一秒的分辨率,因此您也可以将“millis”除以1000并使用它
updateDate = FROM_UNIXTIME( numberofMillisSinceEpoch / 1000 )
If you really need to store date-time information to higher resolution, you could store the milliseconds since epoch in a BIGINT
and roll your own conversion functions.
如果您确实需要将日期时间信息存储到更高的分辨率,那么您可以将纪元以来的毫秒存储在BIGINT中,并滚动自己的转换函数。
If you need to back fill with the current date time (i.e. now) you can use the UNIX_TIMESTAMP()
function with no argument.
如果需要返回当前日期时间(即现在),可以使用UNIX_TIMESTAMP()函数,不带参数。