开发者

Add number of days to a date formatted in MySQL Date in PHP

Is there a way to add a certain number of days to a date formatted like 2010-10-17 without converting it to a unix timestamp lik开发者_如何学运维e using the function strtotime in php?


You can play around with the DateTime library.

So, based on your description, something like the following should do the trick:

$date = new DateTime('2010-10-17');
$date->add(new DateInterval('P10D')); //adding ten days
echo $date->format('Y-m-d') . "\n";

Outputs: 2010-10-27


Although I'm curious as to why you do not want to work with timestamps? As they're the most flexible choice here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜