Vitaliy Yanchuk wrote in post #958983:
> Hello everyone.
>
> Please advice how to get todays month first day and previous month first
> day.
>
> If go on by this post date, it will need to  give me now
> 01-11-2010
> and
> 01-10-2010
>
> or if today was like 3 Jan 2010 it would be
> 01-01-2010
> and
> 01-12-2009

ruby-1.9.2-p0 > today = Time.now
 => 2010-11-03 10:02:46 -0400
ruby-1.9.2-p0 > today.at_beginning_of_month
 => 2010-11-01 00:00:00 -0400
ruby-1.9.2-p0 > today.beginning_of_month
 => 2010-11-01 00:00:00 -0400
ruby-1.9.2-p0 > today.beginning_of_month - 1.month
 => 2010-10-01 00:00:00 -0400

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

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to