Mike Mike -4 years ago 211
Ruby Question

Rails DateTime.now without Time

I need to use DateTime.now to grab the current date, and "strip off" the time.

For example, this shows what I don't want:

DateTime.now => Sat, 19 Nov 2011 18:54:13 UTC +00:00

This shows what I do want:
DateTime.now.some_operation => 2011-11-06 00:00:00 UTC

Answer Source

Try DateTime.now.to_date or DateTime.now.beginning_of_day

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download