在Perl中你可以做到:
my $current_time = DateTime->now();
my $mdy = $current_time->mdy("/");
Run Code Online (Sandbox Code Playgroud)
在Ruby中最简单的方法是什么?
sep*_*p2k 49
该strftime方法可用于格式化时间:
Time.now.strftime("%m/%d/%Y")
Run Code Online (Sandbox Code Playgroud)
%D您可以简单地与strftime方法一起使用
> Time.now.strftime("%D")
=> "11/24/14" # mm/dd/yy
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22782 次 |
| 最近记录: |