The following expression returns the Unix time in milliseconds independent of the time zone.
It sums the number of days passed from the start of the Unix epoch multiplied by the number of milliseconds in a day (24 * 60 * 60 * 1000 = 86400000) plus number of milliseconds past midnight (SSSSS
with a precision of 3 FF3
to express milliseconds).
It uses the SYS_EXTRACT_UTC
method to extract the UTC (Coordinated Universal Timeโformerly Greenwich Mean Time) from the current timestamp (systimestamp
in oracle):
SELECT
EXTRACT(DAY FROM(sys_extract_utc(systimestamp) - to_timestamp('1970-01-01', 'YYYY-MM-DD'))) * 86400000
+ to_number(TO_CHAR(sys_extract_utc(systimestamp), 'SSSSSFF3'))
FROM dual;
Reference -
https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/SYS_EXTRACT_UTC.html
Shared with love from Bookmarks.dev. Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.
Top comments (0)