开发者

PHP mysql adding to a timestamp

开发者 https://www.devze.com 2023-02-12 04:15 出处:网络
I\'m working in PHP with a MySQL db and I have a current timestamp field which is created when the field is made, I then have another field which (when a page is hit) I would like a SQL statement to i

I'm working in PHP with a MySQL db and I have a current timestamp field which is created when the field is made, I then have another field which (when a page is hit) I would like a SQL statement to insert a replica of the timestamp - only 2 days ahead. Any ideas on how I would go about开发者_Python百科 doing this?


So you have a table like:

id
current TIMESTAMP DEFAULT CURRENT..
another TIMESTAMP

?

You can do something like

UPDATE MyTable SET another = ADDDATE(current, INTERVAL 2 DAY) WHERE id = :myId

MySQL Date and Time functions


How about INSERT [...] (... , ADDTIME(NOW(),'2 00:00:00' , ...)

0

精彩评论

暂无评论...
验证码 换一张
取 消