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

前端 未结 4 1220
遇见更好的自我
遇见更好的自我 2020-12-18 18:56

In Perl you can do:

my $current_time = DateTime->now();
my $mdy = $current_time->mdy(\"/\");

What\'s the easiest way to do this in Ru

4条回答
  •  难免孤独
    2020-12-18 19:12

    my $current_time = DateTime->now();
    
    my_current_time = DateTime.now
    
    my $mdy = $current_time->mdy("/");
    
    my_mdy = my_current_time.strftime("%m/%d/%Y")
    

提交回复
热议问题