CURRENT_TIMESTAMP in milliseconds

后端 未结 19 917
失恋的感觉
失恋的感觉 2020-12-07 23:48

Is there any way to get milliseconds out of a timestamp in MySql or PostgreSql (or others just out of curiosity)?

SELECT CURRENT_TI         


        
19条回答
  •  轮回少年
    2020-12-08 00:19

    I felt the need to continue to refine, so in MySQL:

    Current timestamp in milliseconds:

    floor(unix_timestamp(current_timestamp(3)) * 1000)
    

    Timestamp in milliseconds from given datetime(3):

    floor(unix_timestamp("2015-04-27 15:14:55.692") * 1000)
    

    Convert timestamp in milliseconds to datetime(3):

    from_unixtime(1430146422456 / 1000)
    

    Convert datetime(3) to timestamp in milliseconds:

    floor(unix_timestamp("2015-04-27 14:53:42.456") * 1000)
    

提交回复
热议问题