Ruby中格式化日期格式的相关资料
2009-05-11 11:28
274 查看
time.strftime( string ) => string
%a - The abbreviated weekday name (``Sun'') %A - The full weekday name (``Sunday'') %b - The abbreviated month name (``Jan'') %B - The full month name (``January'') %c - The preferred local date and time representation %d - Day of the month (01..31) %H - Hour of the day, 24-hour clock (00..23) %I - Hour of the day, 12-hour clock (01..12) %j - Day of the year (001..366) %m - Month of the year (01..12) %M - Minute of the hour (00..59) %p - Meridian indicator (``AM'' or ``PM'') %S - Second of the minute (00..60) %U - Week number of the current year,starting with the first Sunday as the firstday of the first week (00..53) %W - Week number of the current year,starting with the first Monday as the firstday of the first week (00..53) %w - Day of the week (Sunday is 0, 0..6) %x - Preferred representation for the date alone, no time %X - Preferred representation for the time alone, no date %y - Year without a century (00..99) %Y - Year with century %Z - Time zone name %% - Literal ``%'' character 代码:t = Time.now t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003" t.strftime("at %I:%M%p") #=> "at 08:56AM"
相关文章推荐
- 将数组格式化成json格式(2 相关日期下的 费用)
- java--格式化json日期格式对象 相关实例代码
- SimpleDateFormat格式化日期以及日期的相关操作
- java日期格式化及获取相关总结
- Oracler读取各种格式的相关日期格式
- 【资料下载区】【iCore、 iCore2相关资料】更新日期2017/1/11
- WebApi 返回小驼峰式 json 格式,并格式化日期
- pandas的to_datetime进行字符串格式化成为日期时间格式的方法
- 格式化SharePoint:DateTimeControl 日期时间控件的格式
- JSTL I18N格式标签库之----数字日期格式化
- 后台返回json格式数据日期格式化
- php处理excel时间数据--——使用PHPExcel判别和格式化Excel中的日期格式
- [数据库]日期格式相关参数传递
- element-ui 时间日期选择器格式化为yyyy-mm-dd格式
- 正则表达式练习——将文本中的日期格式化为标准格式
- js格式化日期格式
- 日期格式相关
- 【工具类】关于日期相关类(当前日期加减一、格式化日期)
- WebApi 返回小驼峰式 json 格式,并格式化日期