Tutorial by Examples

DateTime.parse is a very useful method which construct a DateTime from a string, guessing its format. DateTime.parse('Jun, 8 2016') # => #<DateTime: 2016-06-08T00:00:00+00:00 ((2457548j,0s,0n),+0s,2299161j)> DateTime.parse('201603082330') # => #<DateTime: 2016-03-08T23:30:00+00:00...

New

DateTime.new(2014,10,14) # => #<DateTime: 2014-10-14T00:00:00+00:00 ((2456945j,0s,0n),+0s,2299161j)> Current time: DateTime.now # => #<DateTime: 2016-08-04T00:43:58-03:00 ((2457605j,13438s,667386397n),-10800s,2299161j)> Note that it gives the current time in your timezone ...
DateTime + Fixnum (days quantity) DateTime.new(2015,12,30,23,0) + 1 # => #<DateTime: 2015-12-31T23:00:00+00:00 ((2457388j,82800s,0n),+0s,2299161j)> DateTime + Float (days quantity) DateTime.new(2015,12,30,23,0) + 2.5 # => #<DateTime: 2016-01-02T11:00:00+00:00 ((2457390j,39600s,...

Page 1 of 1