How to set the date in mysql update from millisecond from the moment the "epoch" value is received?

I want to populate a few null dates with default dates, which should be an epoch date.

e.g. set updateDate = somethingtoconvertEpochDateToDateTime (numberofMillisSinceEpoch)

+3
source share
1 answer

MySQL DATETIMErepresents only a one-time resolution, so you also divide your millions by 1000 and use

updateDate = FROM_UNIXTIME( numberofMillisSinceEpoch / 1000 )

If you really need to keep date information up to a higher resolution, you can save milliseconds from the era in BIGINTand flip your own conversion functions.

(.. ), UNIX_TIMESTAMP() .

+4

Source: https://habr.com/ru/post/1723405/


All Articles