Created
November 7, 2010 15:50
-
-
Save olistik/666193 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## IS THERE A SIMPLER WAY OF CHANGING some fields of a DateTime Object? | |
real = DateTime.parse(DateTime.now.to_s) | |
fixed = DateTime.new(real.year, real.month, real.day, real.hour, real.minute, real.second) | |
## SOLUTION | |
## http://api.rubyonrails.org/classes/DateTime.html | |
## DateTime#change | |
new_date = DateTime.now.change({year: 2012, sec: 42}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment