Stefan Hansch
Stefan Hansch

Reputation: 1590

How to add 1 month to a DateTime variable?

I have a Subscription model. In my subscriptions table I have a DateTime column called expires_at.

For example:

expires_at: "2013-07-03 08:00:26"

I need to add 30 days more. Which method do I need to use for this?

Upvotes: 4

Views: 7141

Answers (1)

Roman Kiselenko
Roman Kiselenko

Reputation: 44360

Try this:

=> object.expires_at + 1.month
=> Sat, 03 Aug 2013 08:00:26 +0000

Upvotes: 12

Related Questions