How do I format a date to mm/dd/yyyy in Ruby?

ruby, time

Solution

The `strftime` method can be used to format times:

Time.now.strftime("%m/%d/%Y")

Problem

In Perl you can do: ``` my $current_time = DateTime->now(); my $mdy = $current_time->mdy("/"); ``` What's the easiest way to do this in Ruby?

Original source