|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Adding x minutes to a DateTime object
Suppose I have a DateTime object d1, and I want to add x minutes to it to form a second DateTime object d2. How do you do that?
|
|
#2
|
|||
|
|||
|
You can do something like this. I used the variable names you mentioned in the example.
Code:
d2 = d1.advance(:minutes => x) |
|
#3
|
|||
|
|||
|
Thanks for the reply. It's in a Rails application, so I also found an approach using since:
Code:
x.minutes.since d1 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Ruby Programming > Adding x minutes to a DateTime object |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|