Insert server time to Postgres DB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    Insert server time to Postgres DB

    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\htd ocs\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.
    Code:
    $today = strtotime("now");
    Please help me..
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    wouldn't it be easier in this case to use the SQL function NOW()?
    Code:
    INSERT INTO ... VALUES ( NOW() )
    edit: do you pass the timestamp as string or integer value?

    Comment

    Working...