Time in Rails

Alex Wayne wrote:

Stewart wrote:
> Hello,
>
> I have a background in PHP. I have been working with rails for a little
> wihle now and somethign i still am not understanding is how ruby handles
> time stamps. What method can i use to get the current time stamp? Also
> how can i convert that timestamp in to an "english" time?
>
> I need to work out times based on weeks. So for example i would have
> done something like this in php
>
>
> $time_now = time();
> $time_one_week_form_now = 60 * 60 * 24 * 7 + time();
>
> how would i do this in ruby?

easy as pie

  now = Time.now
  then = 1.week.from_now

  puts then.strftime('%Y-%m-%d')
  #=> 2006-11-27

--
Posted via http://www.ruby-forum.com/.

require 'rubygems'
require 'ruby-units'
require 'chronic'

now = 'now'.time
next_week = now + '1 week'.unit