linux 时间戳 转date:
创建自定义函数:
create or replace function unix_to_oracle(in_number number) return date is
begin
return (to_date('','yyyymmdd') + in_number/86400
+ to_number(substr(tz_offset(sessiontimezone),1,3))/24); end unix_to_oracle;
使用:
select unix_to_oracle(1509490525) from dual;
date 转linux时间戳:
create or replace function oracle_to_unix(in_date in date) return number is
begin
return ((in_date-to_date('','yyyymmdd'))*86400 -
to_number(substr(tz_offset(sessiontimezone),1,3))*3600);
end oracle_to_unix;
使用:
select oracle_to_unix(sysdate) from dual;