user17
user17

Reputation: 383

How to add years in DateTime field in php symfony2 doctrine2

I have this as expiry date

$expiryDate = new DateTime();

But that puts expiry date to today time. How can i add 5 years in that time

Upvotes: 2

Views: 8199

Answers (1)

xdazz
xdazz

Reputation: 160873

Check DateTime::modify

$expiryDate->modify('+5 year');

or

$expiryDate = new DateTime('+5 year');

Upvotes: 9

Related Questions