Oracle utility package for getting unix timestamp in milliseconds from dates and timestamps.
SELECT utl_unixtime.current_time_millis FROM dual;
-- returns unix timestamp from database.
SELECT utl_unixtime.date_to_millis(p_date_input => current_date) FROM dual;
-- returns current date as unix timestamp from database.
SELECT utl_unixtime.to_time_millis(p_date_text => '2003/07/09',p_date_format => 'yyyy/mm/dd') FROM dual;
-- returns 1057785728978.
For more examples of datetime formats: function to_date (from dba-oracle.com)
- Download the latest release -- https://github.com/marlonlom/oracle-util-millis/releases
- Extract the zip file
- Use
sql*plus
, or something capable of runningsql*plus
scripts, to run theinstall.sql
script. - To test the implementation, run the
/tests/*.sql
scripts.
NOTICE: Tested in Oracle 11g and 12c.
- install.sql install the utl_unixtime package in your schema.
- src/ source code in PL/SQL, it is accessed by the install script.
- tests/ useful examples to learn how to use utl_unixtime.
Please follow the contributing guidelines to submit fixes or new features.