Skip to content

Instantly share code, notes, and snippets.

@coreymartella
Forked from tobyhede/gist:3179978
Last active September 7, 2017 14:40
Show Gist options
  • Save coreymartella/b9f75760442c084885c9a028c907d569 to your computer and use it in GitHub Desktop.
Save coreymartella/b9f75760442c084885c9a028c907d569 to your computer and use it in GitHub Desktop.
Date format cheat sheet

Server Side (Ruby)

From http://linux.die.net/man/3/strftime

  • %a - The abbreviated weekday name (Sun)
  • %A - The full weekday name (Sunday)
  • %b - The abbreviated month name (Jan)
  • %B - The full month name (January)
  • %d - Day of the month (01..31)
  • %e - Day of the month without leading 0 (1..31)
  • %g - Year in YY (00-99`)
  • %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 first day of the first week (00..53)
  • %W - Week number of the current year, starting with the first Monday as the first day of the first week (00..53)
  • %w - Day of the week (Sunday is 0, 0..6)
  • %y - Year without a century (00..99)
  • %Y - Year with century
  • %Z - Time zone name
  • %% - Literal % character

Client Side (Javascript)

From http://momentjs.com/docs/#/displaying/format/ This format is used for keys matching datetimepicker

  • M - Month of year without leading 0 (1..12)
  • MM - Month of the year (01..12)
  • MMM - The abbreviated month name (Jan)
  • MMMM - The full month name (January)
  • D - Day of the month without leading 0 (1..31)
  • Do - Day of the month without leading 0 and ordinal (1st..31st)
  • DD - Day of the month (01..31)
  • ddd - The abbreviated weekday name (Sun)
  • dddd - The full weekday name (Sunday)
  • YY - Year without a century (00..99)
  • YYYY - Year with century
  • A - Meridian indicator (AM or PM)
  • a - Meridian indicator lowercase (am or pm)
  • H - Hour of the day, 24-hour clock without leading zero (0..23)
  • HH - Hour of the day, 24-hour clock (00..23)
  • h - Hour of the day, 12-hour clock without leading zero (1..12)
  • hh - Hour of the day, 12-hour clock (01..12)
  • mm - Minute of the hour (00..59)
  • ss - Second of the minute (00..60)
  • z - Time zone name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment