Reputation: 3731
I'm able to get approximate time without milliseconds by query
SELECT UNIX_TIMESTAMP(NOW());
but how to get precise current timestamp with milliseconds?
For example, after executing the above query I get 1352717640
value, but I want to get 1352717640xxx
value.
UPD
And other answers from SO (like this) offers solution like
SELECT UNIX_TIMESTAMP(NOW(3))*1000;
but this query only fills up milliseconds place with '000', but I want to get PRECISE value of milliseconds, like 1352717640937
.
In SQLyog:
And in mysql console:
Is it possible at all for MySQL 5.1?
Upvotes: 6
Views: 9436
Reputation: 3580
Mysql 8.0.26
SELECT UNIX_TIMESTAMP(NOW(3))*1000;
-- return float 1672434492831.000
To integer:
SELECT FLOOR(UNIX_TIMESTAMP(NOW(3))*1000);
-- return INT 1672434492831
Upvotes: 2
Reputation: 2480
I think you didn't test it, but yes the solution is
SELECT UNIX_TIMESTAMP(NOW(3))*1000;
MySQL 5.6 Schema Setup:
Query 1:
SELECT UNIX_TIMESTAMP(NOW(3))*1000
| UNIX_TIMESTAMP(NOW(3))*1000 |
|-----------------------------|
| 1519827493419 |
Upvotes: 6