使用php pg_query_参数将unix秒转换为postgres时间戳

使用php pg_query_参数将unix秒转换为postgres时间戳,php,postgresql,unix-timestamp,pg-query,Php,Postgresql,Unix Timestamp,Pg Query,我想使用PHP pg_query_params方法将unix时间戳值插入postgres时间戳列,但遇到了问题 以下是不完整的代码: $con = pg_connect(...); $stmt = 'INSERT INTO my_table (submitted) VALUES ($1)'; $ts = 1479939387; $values = [translate_timestamp_into_sth_postgres_accepts($ts)]; $res = pg_query_param

我想使用PHP pg_query_params方法将unix时间戳值插入postgres时间戳列,但遇到了问题

以下是不完整的代码:

$con = pg_connect(...);
$stmt = 'INSERT INTO my_table (submitted) VALUES ($1)';
$ts = 1479939387;
$values = [translate_timestamp_into_sth_postgres_accepts($ts)];
$res = pg_query_params($con, $stmt, $values);
问:如何将unix秒值转换为postgres接受的值?

使用以下函数:

您的代码可能如下所示(使用默认时区):


就是这样!谢谢你的回答,抱歉耽搁了。
select to_timestamp(1479939387) at time zone 'utc' as tstamp;

       tstamp        
---------------------
 2016-11-23 22:16:27
(1 row)
$con = pg_connect(...);
$stmt = 'INSERT INTO my_table (submitted) VALUES (to_timestamp($1))';
$ts = 1479939387;
$res = pg_query_params($con, $stmt, $ts);