Conversion of long time in mysql

In development, sometimes the date and time are stored in the database in the long type (seconds) for convenience. To query the data here, it needs to be converted.
Just use the from_unixtime function in mysql.

Attach two conversion functions of mysql:

In the mysql database, "2009-09-15 00:00:00" is converted into a function of long integer type:
select unix_timestamp("2013-03-15 00:00:00" )*1000,
it should be noted here that the long integer in the mysql database has fewer milliseconds after the second than the long integer in java, so it needs to be multiplied by 1000, so that the difference is only a few milliseconds.
2. In the mysql database, Convert "1252999488000" (long data in java) to date:
select from_unixtime(1252999488);
[Note]: remove the last three digits

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326395703&siteId=291194637