Connecting Tech Pros Worldwide Help | Site Map

Insert server time to Postgres DB

Familiar Sight
 
Join Date: Jan 2008
Posts: 199
#1: Jul 7 '09
I want to insert current server time to the postgres database. Data type is timestamp. When I insert the date, got an error saying

Warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid input syntax for type timestamp: "1246960321" in C:\Program Files\xampp\htdocs\xxx\xxx\xxx.php on line 57
Error in SQL query: ERROR: invalid input syntax for type timestamp: "1246960321"

I take the time as follows.
Expand|Select|Wrap|Line Numbers
  1. $today = strtotime("now");
Please help me..
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,642
#2: Jul 7 '09

re: Insert server time to Postgres DB


wouldn't it be easier in this case to use the SQL function NOW()?
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO ... VALUES ( NOW() )
edit: do you pass the timestamp as string or integer value?
Reply