linux 时间戳 转date:
 
创建自定义函数:
create or replace function unix_to_oracle(in_number number) return date is
begin
  return (to_date('19700101','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('19700101','yyyymmdd'))*86400 -
  to_number(substr(tz_offset(sessiontimezone),1,3))*3600);
  end oracle_to_unix;

 

 使用:
select oracle_to_unix(sysdate) from dual;

posted on 2017-11-01 18:10  Flink菜鸟  阅读(12386)  评论(0编辑  收藏  举报