http://www.oracle.com/technology/global/cn/pub/articles/oracle_php_cookbook/fuecks_dates.html
Unix时间戳记是从'1970-01-01 00:00:00'GMT开始的秒数,表现为整数型。
Oracle中的时间是Date型,以下函数提供了两种时间转换的Oracle函数 bitscn.com
(1)从Unix时间戳记转换为Oracle时间
create or replace function unix_to_oracle(in_number NUMBER) return date is 网管论坛bbitsCN_com
begin
return(TO_DATE('19700101','yyyymmdd') + in_number/86400 +TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))/24); 中国网管论坛bbsbitsCN.com
end unix_to_oracle;
(2)由Oracle时间Date型转换为Unix时间戳记
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;