mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Advance The Date as a rails til
This commit is contained in:
17
rails/advance-the-date.md
Normal file
17
rails/advance-the-date.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Advance The Date
|
||||
|
||||
In Rails land, you can advance a date forward and backward with the
|
||||
`#advance` method:
|
||||
|
||||
```ruby
|
||||
> Date.today
|
||||
=> Wed, 31 Aug 2016
|
||||
> Date.today.advance(days: 1)
|
||||
=> Thu, 01 Sep 2016
|
||||
> Date.today.advance(months: 1)
|
||||
=> Fri, 30 Sep 2016
|
||||
> Date.today.advance(months: -2)
|
||||
=> Thu, 30 Jun 2016
|
||||
```
|
||||
|
||||
h/t Dillon Hafer
|
||||
Reference in New Issue
Block a user