2008-01-04
ruby学习笔记--Time&DateTime
1,时间的格式化输出
t = Time.now
# to get day, month and year with century
# also hour, minute and second
puts t.strftime("%d/%m/%Y %H:%M:%S")
# You can use the upper case A and B to get the full
# name of the weekday and month, respectively
puts t.strftime("%A")
puts t.strftime("%B")
# You can use the lower case a and b to get the abbreviated
# name of the weekday and month, respectively
puts t.strftime("%a")
puts t.strftime("%b")
# 24 hour clock and Time zone name
puts t.strftime("at %H:%M %Z")
- 08:42
- 浏览 (142)
- 评论 (0)
- 分类: ruby rails
- 相关推荐
发表评论
- 浏览: 2869 次
- 性别:

- 来自: 杭州

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
Rails中启动script/conso ...
补充一下,如果运行: ruby extco ...
-- by dearsuper -
ruby学习笔记--String
闰年定义成方法可以为: def leap_year(year) c ...
-- by minstrel






评论排行榜