I want to insert a unix timestamp value into a postgres timestamp column, using the PHP pg_query_params method, but get stuck.
Here's the incomplete code:
$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);
Q: how to transform the unix seconds value to sth. postgres accepts?
Use the function
to_timestamp(double precision)
:Your code may look like this (using default time zone):