Created
January 27, 2015 12:44
-
-
Save friek/21ad3fd11c176c77f105 to your computer and use it in GitHub Desktop.
MySQL to return the current timestamp + milliseconds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE FUNCTION CURRENT_TIME_MILLIS () | |
| RETURNS BIGINT | |
| LANGUAGE SQL | |
| SQL SECURITY INVOKER | |
| BEGIN | |
| DECLARE _time BIGINT; | |
| select conv(concat(substring(uid,16,3), substring(uid,10,4), substring(uid,1,8)), 16,10) | |
| div 10000 - (141427 * 24 * 60 * 60 * 1000) into _time | |
| from (select uuid() uid) as alias; | |
| return _time; | |
| END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment