开发者

PHP mysql adding to a timestamp

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜