gpt4 book ai didi

php - Now() php 插入日期

转载 作者:行者123 更新时间:2023-11-30 00:19:27 24 4
gpt4 key购买 nike

我使用now()在mysql表insert_date中插入今天的日期和日期,它工作正常,问题是当我尝试插入今天的日期+3年后('+3年')似乎不工作。

php插入代码

$result=mysql_query("INSERT INTO dokument (id, dok_typ, dok_num, namn, url,
insert_date,
update_date) VALUES('','".$dok_typ."',
'".$safe_dok_num."', '".$safe_namn."', '".$filename."', now(),
now()+ interval 3 year");

编辑

用 now() + 间隔 3 年解决问题

它将提供 3 年后今天的日期。

最佳答案

the problem comes to when i try to insert todays date +3 year from now now('+3 year') seems not to work

使用

now() + interval 3 year

作为特定字段查询中的表达式。

顺便说一句:我建议您使用准备好的语句将值与查询绑定(bind),而不是直接将值放在引号之间并提交。

关于php - Now() php 插入日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23360640/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com