如何将日期时间转换为“WEEKDAY,DAY MONTH YEAR”格式

时间:2015-06-10 05:24:13

标签: ruby

如何将datetime对象转换为此格式Thu, 02 July 2015

那是WEEKDAY, DAY MONTH YEAR

1 个答案:

答案 0 :(得分:5)

您应该使用格式字符串:

require 'date'

DateTime.now.strftime("%a, %d %b %Y")
# => "Wed, 10 Jun 2015"
DateTime.now.strftime("%a, %d %B %Y")
# => "Wed, 10 June 2015"