Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在postgres数据库中插入日期_Php_Sql_Postgresql - Fatal编程技术网

Php 在postgres数据库中插入日期

Php 在postgres数据库中插入日期,php,sql,postgresql,Php,Sql,Postgresql,我在php变量中有一天、一个月和一年。知道要插入该日期的字段是日期类型,如何在SQL INSERT语句中使用它们 谢谢。只需将日期格式化为字符串并将其传递给SQL查询即可 $date = sprintf("%04d-%02d-%02d",$year,$month,$day) 您可以使用所需的输入替换$year、$month和$day变量。尝试PHP的date()方法,然后可能与strotime()结合以转换为正确的格式 仅供参考-。

我在php变量中有一天、一个月和一年。知道要插入该日期的字段是日期类型,如何在SQL INSERT语句中使用它们


谢谢。

只需将日期格式化为字符串并将其传递给SQL查询即可

   $date =  sprintf("%04d-%02d-%02d",$year,$month,$day)
您可以使用所需的输入替换$year、$month和$day变量。

尝试PHP的date()方法,然后可能与strotime()结合以转换为正确的格式

仅供参考-。