code.progysm.com

DateTime

Type: objet

Propriétés:
	+ modify(string s)
	+ string format(string f)

Exemples:
	// current date was 2011-11-08
	$myDate = new DateTime();
	$myDate->modify('+100 years');
	var_dump($myDate->format('Y-m-d')); // string(10) "2111-11-08"

	$myDate = new DateTime();
	$myDate->modify('+100 days');
	var_dump($myDate->format('Y-m-d')); // string(10) "2012-02-16"

    // adding/substracting months is not reliable for daily script
    // see the note on secure.php.net/manual/en/datetime.formats.relative.php
    $d = new DateTime('2018-03-31'); $d->modify('-1 month'); echo $d->format('Y-m-d'); // 2018-03-03
    $d = new DateTime('2018-04-03'); $d->modify('-1 month'); echo $d->format('Y-m-d'); // 2018-03-03

Liens:
    secure.php.net/manual/en/datetime.modify.php