strftime cheatsheet

I know there are other cheatsheets out there but I want one that’s close to home. I find myself needing to look up strftime parameters quite often in my Rails development work. Particularly difficult is remembering the different forms for the same time item. Anyway, here is a list formatted for my usage.

Names

  • month name - %b (Abbr), %B (Full)
  • day of week name - %a (Abbr), %A (Full)
  • timezone - %Z (Name), %z (UTC offset)

Dates

  • year - %y (2-digit), %Y (4-digit)
  • month - %m (leading zero)
  • day - %d (leading zero), %e (leading space)
  • hour (24-hour) - %H (leading zero), %k (leading space)
  • hour (12-hour) - %I (leading zero), %l (leading space)
  • am/pm - %p (Uppercase), %P (lowercase)
  • minute - %M (leading zero)
  • second - %S (leading zero)

Trackback URL for this post:

http://hightechsorcery.com/trackback/147
Creative Commons License Except where otherwise noted, content on this site is licensed under a Creative Commons by-nc-sa 3.0 License