V
V
vladislav9972020-05-18 17:43:37
PHP
vladislav997, 2020-05-18 17:43:37

How to set a date and add 30 days to it?

Tell me how to set a date and add 30 days to it? I try like this, but it doesn't work:

$date = new DateTime();
$date->setDate(2001, 2, 3);
echo $date->format('Y-m-d');
echo '<br/>';
echo date($date, strtotime('+30 day'));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2020-05-18
@vladislav997

$date = new DateTime('2006-12-12');
$date->modify('+10 day');
echo $date->format('Y-m-d');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question