postgresql如何插入日期

时间:2018-03-15 20:53:39

标签: php postgresql

如何在postgresql中插入日期?当我错了吗?

public function insert( $name, $author ) {
    $this->query = "INSERT INTO people ( name, author, date )
    VALUES ( '$name', '$author', to_timestamp('2/3/2016 12:05')";

    return $result = pg_query( $this->connection, $this->query );
}

$database->insert( 'someName', 'SomeAuthor' );

1 个答案:

答案 0 :(得分:0)

'2016-03-02 12:05:00'是一种方式......

$this->query = "INSERT INTO people ( name, author, date )
    VALUES ( '$name', '$author', '2016-03-02 12:05:00')";