使用extract函数和epoch关键字即可
select to_timestamp('1970-01-01 00:00:05','YYYY-MM-DD HH24:MI:SS');
>>"1970-01-01 00:00:05+08"
select extract(epoch from to_timestamp('1970-01-01 08:00:05','YYYY-MM-DD HH24:MI:SS'));
>>5
select extract(epoch from now());
>>1494921723.68652