Add 30 days for date in db

2019-07-17 17:09发布

I have publish up date and publish down date in my DB. Currently they are both same dates.

How do I change it (during mysql insert) so publish down date is 30 days past publish up date.

I am using $pubDate

Thanks

2条回答
干净又极端
2楼-- · 2019-07-17 17:30

You can use DATE_ADD():

DATE_ADD(my_date, INTERVAL 30 DAY)
查看更多
神经病院院长
3楼-- · 2019-07-17 17:39

in php, before inserting you can use strtotime(): if the publishDown date is a timestamp:

$publishDown = strtotime("+30 days",$publishDown);

otherwise you may have to use mktime to get it in the right format

查看更多
登录 后发表回答