`
HUYIZIZHEN
  • 浏览: 114162 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

rails date format

    博客分类:
  • ROR
 
阅读更多

   1.Time#strftime
   2.     time.strftime( string ) => string
   3.
   4.     Formats _time_ according to the directives in the given format
   5.     string. Any text not listed as a directive will be passed through
   6.     to the output string.
   7. 
   8.     Format meaning:
   9. 
  10.       %a - The abbreviated weekday name ("Sun")
  11.       %A - The full weekday name ("Sunday")
  12.       %b - The abbreviated month name ("Jan")
  13.       %B - The full month name ("January")
  14.       %c - The preferred local data and time representation
  15.       %d - Day of the month (01..31)
  16.       %H - Hour of the day, 24-hour clock (00..23)
  17.       %I - Hour of the day, 12-hour clock (01..12)
  18.       %j - Day of the year (001..366)
  19.       %m - Month of the year (01..12)
  20.       %M - Minute of the hour (00..59)
  21.       %p - Meridian indicator ("AM" or "PM")
  22.       %S - Second of the minute (00..60)
  23.       %U - Week number of the current year, starting with the first Sunday as the first
  24.               day of the first week (00..53)
  25.       %W - Week number of the current year, starting with the first Monday as the first
  26.               day of the first week (00..53)
  27.       %w - Day of the week (Sunday is 0, 0..6)
  28.       %x - Preferred representation for the date alone, no time
  29.       %X - Preferred representation for the time alone, no date
  30.       %y - Year without a century (00..99)
  31.       %Y - Year with century
  32.       %Z - Time zone name
  33.       %% - Literal "%" character
  34. 
  35.        t = Time.now
  36.        t.strftime("Printed on %m/%d/%Y")  #=> "Printed on 04/09/2003"
  37.        t.strftime("at %I:%M%p)            #=> "at 08:56AM" 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics